Skip to content

Commit dc4d094

Browse files
committed
Fix oss-fuzz-61469: Undef dynamic property in ++/-- unset in error handler
1 parent 1887f02 commit dc4d094

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
OSS Fuzz #61469: Undef variable in ++/-- for dynamic property that is unset in error handler
3+
--FILE--
4+
<?php
5+
class C {
6+
function errorHandle() {
7+
unset($this->a);
8+
}
9+
}
10+
$c = new C;
11+
set_error_handler([$c,'errorHandle']);
12+
13+
($c->a++);
14+
var_dump($c->a);
15+
16+
($c->a--);
17+
var_dump($c->a);
18+
19+
(++$c->a);
20+
var_dump($c->a);
21+
22+
(--$c->a);
23+
var_dump($c->a);
24+
?>
25+
--EXPECT--
26+
NULL
27+
NULL
28+
NULL
29+
NULL

Zend/zend_vm_def.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,11 @@ ZEND_VM_C_LABEL(pre_incdec_object):
13281328
ZVAL_NULL(EX_VAR(opline->result.var));
13291329
}
13301330
} else {
1331+
/* This case can ***ONLY*** happen if get_property_ptr_ptr emits a diagnostic
1332+
* (e.g. undefined property warning) and the propery is unset in the error handler */
1333+
if (UNEXPECTED(Z_TYPE_P(zptr) == IS_UNDEF)) {
1334+
ZVAL_NULL(zptr);
1335+
}
13311336
if (OP2_TYPE == IS_CONST) {
13321337
prop_info = (zend_property_info *) CACHED_PTR_EX(cache_slot + 2);
13331338
} else {

Zend/zend_vm_execute.h

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)