Skip to content

Commit f135ed9

Browse files
committed
Fix memory leak
This fixes oss-fuzz #47527
1 parent 45e623d commit f135ed9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Zend/zend_opcode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,8 @@ static void emit_live_range(
826826
/* The use might have been optimized away, in which case we will hit the def
827827
* instead. */
828828
if (use_opline->opcode == ZEND_COPY_TMP && use_opline->result.var == rt_var_num) {
829+
start = def_opline + 1 - op_array->opcodes;
830+
emit_live_range_raw(op_array, var_num, kind, start, end);
829831
return;
830832
}
831833
} while (!(
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
COALESCE optimization
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function t() {
10+
$y[" $a "] ??= var_dump();
11+
}
12+
t();
13+
?>
14+
--EXPECTF--
15+
Warning: Undefined variable $a in %scoalesce_002.php on line 3
16+
17+
Fatal error: Uncaught ArgumentCountError: var_dump() expects at least 1 argument, 0 given in %scoalesce_002.php:3
18+
Stack trace:
19+
#0 %scoalesce_002.php(3): var_dump()
20+
#1 %scoalesce_002.php(5): t()
21+
#2 {main}
22+
thrown in %scoalesce_002.php on line 3

0 commit comments

Comments
 (0)