Skip to content

Fix op1 leak of error path in post inc/dec #12599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Zend/tests/oss_fuzz_63802.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
oss-fuzz #63802: Post inc/dec with error leaks op1
--FILE--
<?php
class Foo {
public function preInc() {
++$this > 42;
}
public function preDec() {
--$this > 42;
}
public function postInc() {
$this++ > 42;
}
public function postDec() {
$this-- > 42;
}
}
$foo = new Foo();
foreach (['pre', 'post'] as $prePost) {
foreach (['inc', 'dec'] as $incDec) {
try {
$foo->{$prePost . ucfirst($incDec)}();
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
}
}
?>
--EXPECT--
Cannot increment Foo
Cannot decrement Foo
Cannot increment Foo
Cannot decrement Foo
6 changes: 0 additions & 6 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1606,9 +1606,6 @@ ZEND_VM_HELPER(zend_post_inc_helper, VAR|CV, ANY)
ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);

increment_function(var_ptr);
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
} while (0);

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

decrement_function(var_ptr);
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
} while (0);

FREE_OP1();
Expand Down
12 changes: 0 additions & 12 deletions Zend/zend_vm_execute.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.