Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Zend/Optimizer/block_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
&& zend_optimizer_update_op1_const(op_array, opline, &c)) {
VAR_SOURCE(op1) = NULL;
if (opline->opcode != ZEND_JMP_NULL
&& !zend_bitset_in(used_ext, VAR_NUM(src->result.var))) {
&& !zend_bitset_in(used_ext, VAR_NUM(src->result.var))
/* FETCH_W with ZEND_FETCH_GLOBAL_LOCK does not free op1, which will be used again. */
&& (opline->opcode != ZEND_FETCH_W && (opline->extended_value & ZEND_FETCH_GLOBAL_LOCK))) {
Comment thread
iluuu1994 marked this conversation as resolved.
Outdated
literal_dtor(&ZEND_OP1_LITERAL(src));
MAKE_NOP(src);
}
Expand Down
27 changes: 27 additions & 0 deletions ext/opcache/tests/oss-fuzz-481014628.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
OSS-Fuzz #481014628: Borked FETCH_W+ZEND_FETCH_GLOBAL_LOCK optimization
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
--FILE--
<?php

function f() {
return 'foo';
}

function test() {
global ${f()};
var_dump($foo);
}

test();
$foo = 42;
test();

?>
--EXPECT--
NULL
int(42)
Loading