com php-src: Fixed bug #71204 (segfault if clean spl_autoload _funcs while autoloading): NEWS ext/spl/php_spl .c ext/spl/tests/bug71204.phpt
| From: | Xinchen Hui | Date: | Wed, 23 Dec 2015 16:10:59 +0000 |
| Subject: | com php-src: Fixed bug #71204 (segfault if clean spl_autoload _funcs while autoloading): NEWS ext/spl/php_spl .c ext/spl/tests/bug71204.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90420@lists.php.net to get a copy of this message | ||
Commit: 620ccc9b1a0a593786a364af15d45fd797a6cf1f
Author: Xinchen Hui <laruence@gmail.com> Wed, 23 Dec 2015 08:10:59 -0800
Parents: ea12ff149cdcfe04531c7114cf7a3b8e68cd074c
Branches: PHP-5.6 PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=620ccc9b1a0a593786a364af15d45fd797a6cf1f
Log:
Fixed bug #71204 (segfault if clean spl_autoload_funcs while autoloading)
Bugs:
https://bugs.php.net/71204
Changed paths:
M NEWS
M ext/spl/php_spl.c
A ext/spl/tests/bug71204.phpt
Diff:
diff --git a/NEWS b/NEWS
index e460e34..0776f3f 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ PHP NEWS
- Session:
. Fixed bug #71122 (Session GC may not remove obsolete session data). (Yasuo)
+- SPL:
+ . Fixed bug #71204 (segfault if clean spl_autoload_funcs while autoloading).
+ (Laruence)
+
- Standard:
. Fixed bug #70720 (strip_tags improper php code parsing). (Julien)
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 3424b90..d322869 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -669,10 +669,14 @@ PHP_FUNCTION(spl_autoload_unregister)
if (SPL_G(autoload_functions)) {
if (func_name_len == sizeof("spl_autoload_call")-1 && !strcmp(lc_name,
"spl_autoload_call")) {
/* remove all */
- zend_hash_destroy(SPL_G(autoload_functions));
- FREE_HASHTABLE(SPL_G(autoload_functions));
- SPL_G(autoload_functions) = NULL;
- EG(autoload_func) = NULL;
+ if (!SPL_G(autoload_running)) {
+ zend_hash_destroy(SPL_G(autoload_functions));
+ FREE_HASHTABLE(SPL_G(autoload_functions));
+ SPL_G(autoload_functions) = NULL;
+ EG(autoload_func) = NULL;
+ } else {
+ zend_hash_clean(SPL_G(autoload_functions));
+ }
success = SUCCESS;
} else {
/* remove specific */
diff --git a/ext/spl/tests/bug71204.phpt b/ext/spl/tests/bug71204.phpt
new file mode 100644
index 0000000..01a9f3b
--- /dev/null
+++ b/ext/spl/tests/bug71204.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #71204 (segfault if clean spl_autoload_funcs while autoloading )
+--FILE--
+<?php
+
+spl_autoload_register(function ($name) {
+ spl_autoload_unregister("spl_autoload_call");
+});
+
+spl_autoload_register(function ($name) {
+});
+
+new A();
+?>
+--EXPECTF--
+Fatal error: Cannot destroy active lambda function in %sbug71204.php on line %d