Skip to content

Commit 151d2ac

Browse files
committed
Fixed memory leak
Fixes oss-fuzz #45191
1 parent 7eb972c commit 151d2ac

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,13 +1545,13 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
15451545

15461546
dup_partial_object(&zv, op1);
15471547
ct_eval_assign_obj(&zv, &tmp2, op2);
1548-
if (opline->opcode == ZEND_PRE_INC_OBJ
1549-
|| opline->opcode == ZEND_PRE_DEC_OBJ) {
1548+
if (opline->opcode == ZEND_PRE_INC_OBJ || opline->opcode == ZEND_PRE_DEC_OBJ) {
15501549
SET_RESULT(result, &tmp2);
1551-
zval_ptr_dtor_nogc(&tmp1);
15521550
} else {
15531551
SET_RESULT(result, &tmp1);
15541552
}
1553+
zval_ptr_dtor_nogc(&tmp1);
1554+
zval_ptr_dtor_nogc(&tmp2);
15551555
SET_RESULT(op1, &zv);
15561556
zval_ptr_dtor_nogc(&zv);
15571557
break;

ext/opcache/tests/opt/sccp_038.phpt

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

0 commit comments

Comments
 (0)