Skip to content

Commit 4c24545

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79548
2 parents 2dc4481 + 21a9ad9 commit 4c24545

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

Zend/zend_inheritance.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ static zend_function *zend_duplicate_user_function(zend_function *func) /* {{{ *
9797
if (!(GC_FLAGS(new_function->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) {
9898
GC_ADDREF(new_function->op_array.static_variables);
9999
}
100-
ZEND_MAP_PTR_INIT(new_function->op_array.static_variables_ptr, &new_function->op_array.static_variables);
100+
101+
if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) {
102+
ZEND_ASSERT(new_function->op_array.fn_flags & ZEND_ACC_PRELOADED);
103+
ZEND_MAP_PTR_NEW(new_function->op_array.static_variables_ptr);
104+
} else {
105+
ZEND_MAP_PTR_INIT(new_function->op_array.static_variables_ptr, &new_function->op_array.static_variables);
106+
}
107+
101108
return new_function;
102109
}
103110
/* }}} */
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
class A {
4+
public function test() {
5+
static $foo;
6+
}
7+
}
8+
9+
class B extends A {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #79548: Preloading segfault with inherited method using static variable
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.preload={PWD}/preload_static_var_inheritance.inc
8+
--SKIPIF--
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
13+
--FILE--
14+
<?php
15+
var_dump((new B)->test());
16+
?>
17+
--EXPECT--
18+
NULL

0 commit comments

Comments
 (0)