From 620ccc9b1a0a593786a364af15d45fd797a6cf1f Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 23 Dec 2015 08:10:59 -0800 Subject: [PATCH] Fixed bug #71204 (segfault if clean spl_autoload_funcs while autoloading) --- NEWS | 4 ++++ ext/spl/php_spl.c | 12 ++++++++---- ext/spl/tests/bug71204.phpt | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 ext/spl/tests/bug71204.phpt 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-- + +--EXPECTF-- +Fatal error: Cannot destroy active lambda function in %sbug71204.php on line %d -- 2.40.0