From: Antony Dovgal Date: Mon, 9 Apr 2007 07:30:09 +0000 (+0000) Subject: fix #41026 (segfault when calling "self::method()" in shutdown functions) X-Git-Tag: php-5.2.2RC1~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2e2994a6e809b2d96fb746f4e7dbd0e1fb88999;p=php fix #41026 (segfault when calling "self::method()" in shutdown functions) --- diff --git a/Zend/tests/bug41026.phpt b/Zend/tests/bug41026.phpt new file mode 100644 index 0000000000..7caac215e0 --- /dev/null +++ b/Zend/tests/bug41026.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #41026 (segfault when calling "self::method()" in shutdown functions) +--FILE-- + +--EXPECTF-- +Done + +Warning: (Registered shutdown functions) Unable to call self::on_shutdown() - function does not exist in Unknown on line 0 diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 1524031dee..d3f58f660e 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -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;