diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 4861e45..72aba25 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -568,6 +568,18 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
}
Z_FE_POS(generator->values) = pos;
+ } if (Z_TYPE(generator->values) == IS_STRING) {
+ if (UNEXPECTED(Z_FE_POS(generator->values) >= Z_STRLEN(generator->values))) {
+ goto failure;
+ }
+
+ if (Z_TYPE(generator->value) != IS_UNDEF) {
+ zval_ptr_dtor(&generator->value);