Commit 28e21d80b0 for php.net

commit 28e21d80b0fdee7e4b605adc007f9645a0d830c6
Author: Nikita Popov <nikita.ppv@gmail.com>
Date:   Fri Oct 16 16:57:50 2020 +0200

    Fix leak when setting dynamic property on generator

diff --git a/Zend/tests/generators/dynamic_properties.phpt b/Zend/tests/generators/dynamic_properties.phpt
index d42eed914a..08ceb7f581 100644
--- a/Zend/tests/generators/dynamic_properties.phpt
+++ b/Zend/tests/generators/dynamic_properties.phpt
@@ -9,7 +9,7 @@ function gen() {

 $gen = gen();
 try {
-    $gen->prop = 42;
+    $gen->prop = new stdClass;
 } catch (Error $e) {
     echo $e->getMessage(), "\n";
 }
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index ecf5c71ed8..f091d679f6 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -772,11 +772,10 @@ found:
 	} else {
 		ZEND_ASSERT(!IS_WRONG_PROPERTY_OFFSET(property_offset));
 write_std_property:
-		Z_TRY_ADDREF_P(value);
 		if (EXPECTED(IS_VALID_PROPERTY_OFFSET(property_offset))) {
-
 			variable_ptr = OBJ_PROP(zobj, property_offset);

+			Z_TRY_ADDREF_P(value);
 			if (UNEXPECTED(prop_info)) {
 				ZVAL_COPY_VALUE(&tmp, value);
 				if (UNEXPECTED(!zend_verify_property_type(prop_info, &tmp, property_uses_strict_types()))) {
@@ -794,6 +793,8 @@ write_std_property:
 				variable_ptr = &EG(error_zval);
 				goto exit;
 			}
+
+			Z_TRY_ADDREF_P(value);
 			if (!zobj->properties) {
 				rebuild_object_properties(zobj);
 			}