Skip to content

Commit 6d00788

Browse files
committed
Backup value
1 parent d9d3ed1 commit 6d00788

File tree

2 files changed

+15
-116
lines changed

2 files changed

+15
-116
lines changed

Zend/tests/lazy_objects/gh15999.phpt

Lines changed: 0 additions & 107 deletions
This file was deleted.

Zend/zend_object_handlers.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,16 +1184,22 @@ found:;
11841184
return variable_ptr;
11851185

11861186
lazy_init:
1187-
zobj = zend_lazy_object_init(zobj);
1188-
if (UNEXPECTED(!zobj)) {
1189-
variable_ptr = &EG(error_zval);
1190-
goto exit;
1191-
}
1192-
/* value may have changed during initialization */
1193-
if (UNEXPECTED(Z_ISREF_P(value))) {
1194-
value = Z_REFVAL_P(value);
1187+
{
1188+
/* backup value as it may change during initialization */
1189+
zval backup;
1190+
ZVAL_COPY(&backup, value);
1191+
1192+
zobj = zend_lazy_object_init(zobj);
1193+
if (UNEXPECTED(!zobj)) {
1194+
variable_ptr = &EG(error_zval);
1195+
zval_ptr_dtor(&backup);
1196+
goto exit;
1197+
}
1198+
1199+
variable_ptr = zend_std_write_property(zobj, name, &backup, cache_slot);
1200+
zval_ptr_dtor(&backup);
1201+
return variable_ptr;
11951202
}
1196-
return zend_std_write_property(zobj, name, value, cache_slot);
11971203
}
11981204
/* }}} */
11991205

0 commit comments

Comments
 (0)