Skip to content

Commit 7e022ea

Browse files
authored
Avoid duplicate code in zend_std_write_property() (#14966)
1 parent a2bc783 commit 7e022ea

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

Zend/zend_object_handlers.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zva
961961
goto exit;
962962
}
963963

964+
typed_property:
964965
ZVAL_COPY_VALUE(&tmp, value);
965966
// Increase refcount to prevent object from being released in __toString()
966967
GC_ADDREF(zobj);
@@ -977,7 +978,7 @@ ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zva
977978
variable_ptr = &EG(error_zval);
978979
goto exit;
979980
}
980-
Z_PROP_FLAG_P(variable_ptr) &= ~IS_PROP_REINITABLE;
981+
Z_PROP_FLAG_P(variable_ptr) &= ~(IS_PROP_UNINIT|IS_PROP_REINITABLE);
981982
value = &tmp;
982983
}
983984

@@ -1105,25 +1106,7 @@ found:;
11051106
variable_ptr = &EG(error_zval);
11061107
goto exit;
11071108
}
1108-
1109-
ZVAL_COPY_VALUE(&tmp, value);
1110-
// Increase refcount to prevent object from being released in __toString()
1111-
GC_ADDREF(zobj);
1112-
bool type_matched = zend_verify_property_type(prop_info, &tmp, property_uses_strict_types());
1113-
if (UNEXPECTED(GC_DELREF(zobj) == 0)) {
1114-
zend_object_released_while_assigning_to_property_error(prop_info);
1115-
zend_objects_store_del(zobj);
1116-
zval_ptr_dtor(&tmp);
1117-
variable_ptr = &EG(error_zval);
1118-
goto exit;
1119-
}
1120-
if (UNEXPECTED(!type_matched)) {
1121-
zval_ptr_dtor(value);
1122-
goto exit;
1123-
}
1124-
value = &tmp;
1125-
Z_PROP_FLAG_P(variable_ptr) = 0;
1126-
goto found; /* might have been updated via e.g. __toString() */
1109+
goto typed_property;
11271110
}
11281111

11291112
ZVAL_COPY_VALUE(variable_ptr, value);

0 commit comments

Comments
 (0)