fix #41026 (segfault when calling "self::method()" in shutdown functions)

This commit is contained in:
Antony Dovgal 2007-04-09 07:30:09 +00:00
parent 65afdf097c
commit b2e2994a6e
2 changed files with 28 additions and 2 deletions

26
Zend/tests/bug41026.phpt Normal file
View File

@ -0,0 +1,26 @@
--TEST--
Bug #41026 (segfault when calling "self::method()" in shutdown functions)
--FILE--
<?php
class try_class
{
static public function main ()
{
register_shutdown_function (array ("self", "on_shutdown"));
}
static public function on_shutdown ()
{
printf ("CHECKPOINT\n"); /* never reached */
}
}
try_class::main ();
echo "Done\n";
?>
--EXPECTF--
Done
Warning: (Registered shutdown functions) Unable to call self::on_shutdown() - function does not exist in Unknown on line 0

View File

@ -2262,9 +2262,9 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, uint check_flags, char **
}
lcname = zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
if (Z_STRLEN_PP(obj) == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self")) == 0) {
if (Z_STRLEN_PP(obj) == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self")) == 0 && EG(active_op_array)) {
ce = EG(active_op_array)->scope;
} else if (Z_STRLEN_PP(obj) == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent")) == 0 && EG(active_op_array)->scope) {
} else if (Z_STRLEN_PP(obj) == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent")) == 0 && EG(active_op_array) && EG(active_op_array)->scope) {
ce = EG(active_op_array)->scope->parent;
} else if (zend_lookup_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) {
ce = *pce;