summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-12-23 08:10:59 -0800
committerXinchen Hui <laruence@gmail.com>2015-12-23 08:10:59 -0800
commit620ccc9b1a0a593786a364af15d45fd797a6cf1f (patch)
tree425967a7187d100ca47e4cd812fd1030e69ae3a0
parentea12ff149cdcfe04531c7114cf7a3b8e68cd074c (diff)
downloadphp-git-620ccc9b1a0a593786a364af15d45fd797a6cf1f.tar.gz
Fixed bug #71204 (segfault if clean spl_autoload_funcs while autoloading)
-rw-r--r--NEWS4
-rw-r--r--ext/spl/php_spl.c12
-rw-r--r--ext/spl/tests/bug71204.phpt16
3 files changed, 28 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index e460e3438e..0776f3f5f8 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 3424b90aea..d3228698de 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 0000000000..01a9f3bcaf
--- /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