svn: /php/php-src/ branches/PHP_5_4/Zend/tests/bug60444.phpt branches/PHP_5_4/Zend/zend_compile.c trunk/Zend/tests/bug60444.phpt
trunk/Zend/zend_compile.c
| From: | Dmitry Stogov | Date: | Mon, 05 Dec 2011 09:20:12 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_4/Zend/tests/bug60444.phpt branches/PHP_5_4/Zend/zend_compile.c trunk/Zend/tests/bug60444.phpt trunk/Zend/zend_compile.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-67193@lists.php.net to get a copy of this message | ||
dmitry Mon, 05 Dec 2011 09:20:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=320403
Log:
Fixed bug #60444 (Segmentation fault with include & class extending)
Bug: https://bugs.php.net/60444 (Assigned) Segmentation
fault with include & class extending
Changed paths:
A php/php-src/branches/PHP_5_4/Zend/tests/bug60444.phpt
U php/php-src/branches/PHP_5_4/Zend/zend_compile.c
A php/php-src/trunk/Zend/tests/bug60444.phpt
U php/php-src/trunk/Zend/zend_compile.c
Added: php/php-src/branches/PHP_5_4/Zend/tests/bug60444.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug60444.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug60444.phpt 2011-12-05 09:20:12 UTC (rev 320403)
@@ -0,0 +1,18 @@
+--TEST--
+Bug #60444 (Segmentation fault with include & class extending)
+--FILE--
+<?php
+class Foo {
+ public function __construct() {
+ eval("class Bar extends Foo {}");
+ Some::foo($this);
+ }
+}
+class Some {
+ public static function foo(Foo $foo) {
+ }
+}
+new Foo;
+echo "done\n";
+--EXPECT--
+done
Modified: php/php-src/branches/PHP_5_4/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend_compile.c 2011-12-05 08:23:19 UTC (rev 320402)
+++ php/php-src/branches/PHP_5_4/Zend/zend_compile.c 2011-12-05 09:20:12 UTC (rev 320403)
@@ -2809,7 +2809,7 @@
static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
{
- zend_function *function;
+ zend_function *function, *new_function;
if (!ce->parent) {
return;
@@ -2870,8 +2870,8 @@
if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **)&function)==SUCCESS) {
/* inherit parent's constructor */
- zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL);
- function_add_ref(function);
+ zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), (void**)&new_function);
+ function_add_ref(new_function);
} else {
/* Don't inherit the old style constructor if we already have the new style constructor */
char *lc_class_name;
@@ -2884,8 +2884,8 @@
zend_hash_find(&ce->parent->function_table, lc_parent_class_name,
ce->parent->name_length+1, (void **)&function)==SUCCESS) {
if (function->common.fn_flags & ZEND_ACC_CTOR) {
/* inherit parent's constructor */
- zend_hash_update(&ce->function_table, lc_parent_class_name,
ce->parent->name_length+1, function, sizeof(zend_function), NULL);
- function_add_ref(function);
+ zend_hash_update(&ce->function_table, lc_parent_class_name,
ce->parent->name_length+1, function, sizeof(zend_function), (void**)new_function);
+ function_add_ref(new_function);
}
}
efree(lc_parent_class_name);
Added: php/php-src/trunk/Zend/tests/bug60444.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug60444.phpt (rev 0)
+++ php/php-src/trunk/Zend/tests/bug60444.phpt 2011-12-05 09:20:12 UTC (rev 320403)
@@ -0,0 +1,18 @@
+--TEST--
+Bug #60444 (Segmentation fault with include & class extending)
+--FILE--
+<?php
+class Foo {
+ public function __construct() {
+ eval("class Bar extends Foo {}");
+ Some::foo($this);
+ }
+}
+class Some {
+ public static function foo(Foo $foo) {
+ }
+}
+new Foo;
+echo "done\n";
+--EXPECT--
+done
Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c 2011-12-05 08:23:19 UTC (rev 320402)
+++ php/php-src/trunk/Zend/zend_compile.c 2011-12-05 09:20:12 UTC (rev 320403)
@@ -2809,7 +2809,7 @@
static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
{
- zend_function *function;
+ zend_function *function, *new_function;
if (!ce->parent) {
return;
@@ -2870,8 +2870,8 @@
if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **)&function)==SUCCESS) {
/* inherit parent's constructor */
- zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL);
- function_add_ref(function);
+ zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME,
sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), (void**)&new_function);
+ function_add_ref(new_function);
} else {
/* Don't inherit the old style constructor if we already have the new style constructor */
char *lc_class_name;
@@ -2884,8 +2884,8 @@
zend_hash_find(&ce->parent->function_table, lc_parent_class_name,
ce->parent->name_length+1, (void **)&function)==SUCCESS) {
if (function->common.fn_flags & ZEND_ACC_CTOR) {
/* inherit parent's constructor */
- zend_hash_update(&ce->function_table, lc_parent_class_name,
ce->parent->name_length+1, function, sizeof(zend_function), NULL);
- function_add_ref(function);
+ zend_hash_update(&ce->function_table, lc_parent_class_name,
ce->parent->name_length+1, function, sizeof(zend_function), (void**)new_function);
+ function_add_ref(new_function);
}
}
efree(lc_parent_class_name);