Skip to content

Commit ddabe89

Browse files
committed
Fix OP1 leak in error path of post inc/dec
Fixes oss-fuzz #63802 Closes GH-12599
1 parent 83bbea7 commit ddabe89

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PHP NEWS
1212
. Fixed max_execution_time: don't delete an unitialized timer. (Kévin Dunglas)
1313
. Fixed bug GH-12558 (Arginfo soft-breaks with namespaced class return type
1414
if the class name starts with N). (kocsismate)
15+
. Fixed oss-fuzz #63802 (OP1 leak in error path of post inc/dec). (ilutov)
1516

1617
- DOM:
1718
. Fix registerNodeClass with abstract class crashing. (nielsdos)

Zend/tests/oss_fuzz_63802.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
oss-fuzz #63802: OP1 leak in error path of post inc/dec
3+
--FILE--
4+
<?php
5+
class Foo {
6+
public function preInc() {
7+
++$this > 42;
8+
}
9+
public function preDec() {
10+
--$this > 42;
11+
}
12+
public function postInc() {
13+
$this++ > 42;
14+
}
15+
public function postDec() {
16+
$this-- > 42;
17+
}
18+
}
19+
$foo = new Foo();
20+
foreach (['pre', 'post'] as $prePost) {
21+
foreach (['inc', 'dec'] as $incDec) {
22+
try {
23+
$foo->{$prePost . ucfirst($incDec)}();
24+
} catch (TypeError $e) {
25+
echo $e->getMessage(), "\n";
26+
}
27+
}
28+
}
29+
?>
30+
--EXPECT--
31+
Cannot increment Foo
32+
Cannot decrement Foo
33+
Cannot increment Foo
34+
Cannot decrement Foo

Zend/zend_vm_def.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,9 +1606,6 @@ ZEND_VM_HELPER(zend_post_inc_helper, VAR|CV, ANY)
16061606
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
16071607

16081608
increment_function(var_ptr);
1609-
if (UNEXPECTED(EG(exception))) {
1610-
HANDLE_EXCEPTION();
1611-
}
16121609
} while (0);
16131610

16141611
FREE_OP1();
@@ -1657,9 +1654,6 @@ ZEND_VM_HELPER(zend_post_dec_helper, VAR|CV, ANY)
16571654
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
16581655

16591656
decrement_function(var_ptr);
1660-
if (UNEXPECTED(EG(exception))) {
1661-
HANDLE_EXCEPTION();
1662-
}
16631657
} while (0);
16641658

16651659
FREE_OP1();

Zend/zend_vm_execute.h

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

0 commit comments

Comments
 (0)