Skip to content

Commit

Permalink
Fix memory leak in SCCP
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #42878
  • Loading branch information
dstogov committed Dec 24, 2021
1 parent 3f0bb67 commit 2b81156
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/opcache/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
if (opline->opcode == ZEND_PRE_INC_OBJ
|| opline->opcode == ZEND_PRE_DEC_OBJ) {
SET_RESULT(result, &tmp2);
zval_ptr_dtor_nogc(&tmp1);
} else {
SET_RESULT(result, &tmp1);
}
Expand Down
17 changes: 17 additions & 0 deletions ext/opcache/tests/opt/sccp_035.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
SCCP 035: memory leak
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--FILE--
<?php
function test() {
$obj = new stdClass;
$obj->$b = ~$b = $a='';
$obj->$a--;
}
?>
DONE
--EXPECT--
DONE

0 comments on commit 2b81156

Please sign in to comment.