mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Fix null static_variable_ptr for uncalled fake closures
Closes GH-8083 Closes GH-8109
This commit is contained in:
parent
afbb9b9a1b
commit
19063a84f0
2
NEWS
2
NEWS
@ -5,6 +5,8 @@ PHP NEWS
|
||||
- Core:
|
||||
. Fixed Haiku ZTS build. (David Carlier)
|
||||
. Fixed bug GH-8059 arginfo not regenerated for extension. (Remi)
|
||||
. Fixed bug GH-8083 Segfault when dumping uncalled fake closure with static
|
||||
variables. (ilutov)
|
||||
|
||||
- GD:
|
||||
. Fixed libpng warning when loading interlaced images. (Brett)
|
||||
|
22
Zend/tests/gh8083.phpt
Normal file
22
Zend/tests/gh8083.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
GH-8083 (var_dump() on closure with static variable segfaults)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function func() {
|
||||
static $i;
|
||||
}
|
||||
|
||||
$x = func(...);
|
||||
|
||||
var_dump($x);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
object(Closure)#1 (1) {
|
||||
["static"]=>
|
||||
array(1) {
|
||||
["i"]=>
|
||||
NULL
|
||||
}
|
||||
}
|
@ -697,6 +697,13 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
|
||||
}
|
||||
ZEND_MAP_PTR_INIT(closure->func.op_array.static_variables_ptr,
|
||||
&closure->func.op_array.static_variables);
|
||||
} else if (func->op_array.static_variables) {
|
||||
HashTable *ht = ZEND_MAP_PTR_GET(func->op_array.static_variables_ptr);
|
||||
|
||||
if (!ht) {
|
||||
ht = zend_array_dup(func->op_array.static_variables);
|
||||
ZEND_MAP_PTR_SET(closure->func.op_array.static_variables_ptr, ht);
|
||||
}
|
||||
}
|
||||
|
||||
/* Runtime cache is scope-dependent, so we cannot reuse it if the scope changed */
|
||||
|
Loading…
Reference in New Issue
Block a user