Skip to content

Commit ec4887b

Browse files
committed
Fix property write leak
1 parent f3be8d1 commit ec4887b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Diff for: src/store.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -450,21 +450,23 @@ zend_bool pmmpthread_store_isset(zend_object *object, zval *key, int has_set_exi
450450
} /* }}} */
451451

452452
static inline void pmmpthread_store_update_local_property(zend_object* object, zval* key, zend_property_info* prop_info, zval* value) {
453-
Z_TRY_ADDREF_P(value);
454-
455453
zval* property;
456454
if (prop_info != NULL && prop_info != ZEND_WRONG_PROPERTY_INFO) {
455+
Z_TRY_ADDREF_P(value);
457456
property = OBJ_PROP(object, prop_info->offset);
458457
zval_ptr_dtor(property);
459458
ZVAL_COPY_VALUE(property, value);
460459
} else {
461460
pmmpthread_store_init_local_properties(object);
462-
if (Z_TYPE_P(key) == IS_LONG) {
463-
zend_hash_index_update(object->properties, Z_LVAL_P(key), value);
464-
} else {
465-
zend_string* str_key = Z_STR_P(key);
466-
property = zend_hash_find(object->properties, str_key);
467-
if (property != value) {
461+
property = Z_TYPE_P(key) == IS_LONG ?
462+
zend_hash_index_find(object->properties, Z_LVAL_P(key)) :
463+
zend_hash_find(object->properties, Z_STR_P(key));
464+
if (property != value) {
465+
Z_TRY_ADDREF_P(value);
466+
if (Z_TYPE_P(key) == IS_LONG) {
467+
zend_hash_index_update(object->properties, Z_LVAL_P(key), value);
468+
} else {
469+
zend_string* str_key = Z_STR_P(key);
468470
//update_ind() ensures defined properties get properly updated even if we didn't have prop_info
469471
if ((GC_FLAGS(str_key) & (IS_STR_PERSISTENT | IS_STR_INTERNED)) == IS_STR_PERSISTENT) {
470472
//refcounted persistent string from pmmpthread_store - we can't use it directly

0 commit comments

Comments
 (0)