Skip to content

Commit d204750

Browse files
committed
Fixed bug #75420 (Crash when modifing property name in __isset for BP_VAR_IS)
1 parent 578ba71 commit d204750

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ PHP NEWS
33
?? ??? 2017 PHP 7.0.26
44

55
- Core:
6+
. Fixed bug #75420 (Crash when modifing property name in __isset for
7+
BP_VAR_IS). (Laruence)
68
. Fixed bug #75368 (mmap/munmap trashing on unlucky allocations). (Nikita,
79
Dmitry)
810

Zend/tests/bug75420.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #75420 (Crash when modifing property name in __isset for BP_VAR_IS)
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public function __isset($x) { $GLOBALS["name"] = 24; return true; }
8+
public function __get($x) { var_dump($x); return 42; }
9+
}
10+
11+
$obj = new Test;
12+
$name = "foo";
13+
var_dump($obj->$name ?? 12);
14+
?>
15+
--EXPECT--

Zend/zend_object_handlers.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
510510
zval tmp_member;
511511
zval *retval;
512512
uint32_t property_offset;
513+
zend_long *guard = NULL;
513514

514515
zobj = Z_OBJ_P(object);
515516

@@ -545,7 +546,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
545546
/* magic isset */
546547
if ((type == BP_VAR_IS) && zobj->ce->__isset) {
547548
zval tmp_object, tmp_result;
548-
zend_long *guard = zend_get_property_guard(zobj, Z_STR_P(member));
549+
guard = zend_get_property_guard(zobj, Z_STR_P(member));
549550

550551
if (!((*guard) & IN_ISSET)) {
551552
ZVAL_COPY(&tmp_object, object);
@@ -569,7 +570,9 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
569570

570571
/* magic get */
571572
if (zobj->ce->__get) {
572-
zend_long *guard = zend_get_property_guard(zobj, Z_STR_P(member));
573+
if (guard == NULL) {
574+
guard = zend_get_property_guard(zobj, Z_STR_P(member));
575+
}
573576
if (!((*guard) & IN_GET)) {
574577
zval tmp_object;
575578

0 commit comments

Comments
 (0)