Fix invalid returned opcode for memoized expressions

Closes GH-12345
This commit is contained in:
Ilija Tovilo 2023-10-02 15:20:13 +02:00
parent f7cef9a242
commit 4ba5699903
No known key found for this signature in database
GPG Key ID: A4F5D403F118200A
3 changed files with 11 additions and 1 deletions

1
NEWS
View File

@ -4,6 +4,7 @@ PHP NEWS
- Core:
. Fixed bug #80092 (ZTS + preload = segfault on shutdown). (nielsdos)
. Fixed buffer underflow when compiling memoized expression. (ilutov)
- CType:
. Fixed bug GH-11997 (ctype_alnum 5 times slower in PHP 8.1 or greater).

View File

@ -0,0 +1,8 @@
--TEST--
Invalid opcode returned from zend_compile_var_inner() for memoized expression
--FILE--
<?php
strlen("foo")[0] ??= 123;
?>
--EXPECTF--
Fatal error: Cannot use result of built-in function in write context in %s on line %d

View File

@ -10616,7 +10616,8 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
case ZEND_AST_NULLSAFE_METHOD_CALL:
case ZEND_AST_STATIC_CALL:
zend_compile_memoized_expr(result, ast);
return &CG(active_op_array)->opcodes[CG(active_op_array)->last - 1];
/* This might not actually produce an opcode, e.g. for expressions evaluated at comptime. */
return NULL;
}
}