Skip to content

Commit

Permalink
JIT: Fixed memory leak in BOOL_NOT when opearnd ia a reference to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 16, 2021
1 parent 83f283f commit 5e3eaf1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit_x86.dasc
Expand Up @@ -8309,7 +8309,7 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
return 1;
}

if (op1_info & MAY_BE_REF) {
if (opline->op1_type == IS_CV && (op1_info & MAY_BE_REF)) {
| LOAD_ZVAL_ADDR FCARG1a, op1_addr
| ZVAL_DEREF FCARG1a, op1_info
op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);
Expand Down
21 changes: 21 additions & 0 deletions ext/opcache/tests/jit/bool_not_001.phpt
@@ -0,0 +1,21 @@
--TEST--
JIT BOOL_NOT: 001 Memory leak in case of reference to bool
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
opcache.jit=function
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
function test() {
$a = true;
var_dump(!$b =& $a);
}
test();
?>
--EXPECT--
bool(false)

0 comments on commit 5e3eaf1

Please sign in to comment.