Fix memory leak

This fixes oss-fuzz #47527
This commit is contained in:
Dmitry Stogov 2022-05-23 13:33:20 +03:00
parent 45e623da26
commit f135ed9a8a
2 changed files with 24 additions and 0 deletions

View file

@ -826,6 +826,8 @@ done:
/* The use might have been optimized away, in which case we will hit the def
* instead. */
if (use_opline->opcode == ZEND_COPY_TMP && use_opline->result.var == rt_var_num) {
start = def_opline + 1 - op_array->opcodes;
emit_live_range_raw(op_array, var_num, kind, start, end);
return;
}
} while (!(

View file

@ -0,0 +1,22 @@
--TEST--
COALESCE optimization
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--FILE--
<?php
function t() {
$y[" $a "] ??= var_dump();
}
t();
?>
--EXPECTF--
Warning: Undefined variable $a in %scoalesce_002.php on line 3
Fatal error: Uncaught ArgumentCountError: var_dump() expects at least 1 argument, 0 given in %scoalesce_002.php:3
Stack trace:
#0 %scoalesce_002.php(3): var_dump()
#1 %scoalesce_002.php(5): t()
#2 {main}
thrown in %scoalesce_002.php on line 3