Skip to content

Commit 2b81156

Browse files
committed
Fix memory leak in SCCP
Fixes oss-fuzz #42878
1 parent 3f0bb67 commit 2b81156

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
15471547
if (opline->opcode == ZEND_PRE_INC_OBJ
15481548
|| opline->opcode == ZEND_PRE_DEC_OBJ) {
15491549
SET_RESULT(result, &tmp2);
1550+
zval_ptr_dtor_nogc(&tmp1);
15501551
} else {
15511552
SET_RESULT(result, &tmp1);
15521553
}

ext/opcache/tests/opt/sccp_035.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
SCCP 035: memory leak
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function test() {
10+
$obj = new stdClass;
11+
$obj->$b = ~$b = $a='';
12+
$obj->$a--;
13+
}
14+
?>
15+
DONE
16+
--EXPECT--
17+
DONE

0 commit comments

Comments
 (0)