Skip to content

Commit c110f63

Browse files
arnaud-lbGirgias
authored andcommitted
Fix memory leak
1 parent c5eb8c3 commit c110f63

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Zend/Optimizer/sccp.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,21 +1381,22 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
13811381
&& ctx->scdf.ssa->vars[ssa_op->op1_def].escape_state == ESCAPE_STATE_NO_ESCAPE) {
13821382
zval tmp1, tmp2;
13831383

1384-
if (ct_eval_fetch_obj(&tmp1, op1, op2) == SUCCESS
1385-
&& ct_eval_incdec(&tmp2, opline->opcode, &tmp1) == SUCCESS) {
1386-
1387-
dup_partial_object(&zv, op1);
1388-
ct_eval_assign_obj(&zv, &tmp2, op2);
1389-
if (opline->opcode == ZEND_PRE_INC_OBJ || opline->opcode == ZEND_PRE_DEC_OBJ) {
1390-
SET_RESULT(result, &tmp2);
1391-
} else {
1392-
SET_RESULT(result, &tmp1);
1384+
if (ct_eval_fetch_obj(&tmp1, op1, op2) == SUCCESS) {
1385+
if (ct_eval_incdec(&tmp2, opline->opcode, &tmp1) == SUCCESS) {
1386+
dup_partial_object(&zv, op1);
1387+
ct_eval_assign_obj(&zv, &tmp2, op2);
1388+
if (opline->opcode == ZEND_PRE_INC_OBJ || opline->opcode == ZEND_PRE_DEC_OBJ) {
1389+
SET_RESULT(result, &tmp2);
1390+
} else {
1391+
SET_RESULT(result, &tmp1);
1392+
}
1393+
zval_ptr_dtor_nogc(&tmp1);
1394+
zval_ptr_dtor_nogc(&tmp2);
1395+
SET_RESULT(op1, &zv);
1396+
zval_ptr_dtor_nogc(&zv);
1397+
break;
13931398
}
13941399
zval_ptr_dtor_nogc(&tmp1);
1395-
zval_ptr_dtor_nogc(&tmp2);
1396-
SET_RESULT(op1, &zv);
1397-
zval_ptr_dtor_nogc(&zv);
1398-
break;
13991400
}
14001401
}
14011402
}

ext/opcache/tests/opt/sccp_035.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ function test() {
1313
}
1414
?>
1515
DONE
16-
--EXPECTF--
17-
Deprecated: Decrement on empty string is deprecated as non-numeric in %ssccp_035.php on line 5
16+
--EXPECT--
1817
DONE

0 commit comments

Comments
 (0)