Skip to content

Commit 9a69bb2

Browse files
committed
Add missing NULL checks for spl autoload table
Closes GH-12840.
1 parent bedf108 commit 9a69bb2

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PHP NEWS
99
php_message_handler_for_zend). (ilutov)
1010
. Fixed bug GH-12758 / GH-12768 (Invalid opline in OOM handlers within
1111
ZEND_FUNC_GET_ARGS and ZEND_BIND_STATIC). (Florian Engelhardt)
12+
. Fix various missing NULL checks. (nielsdos, dstogov)
1213

1314
- Date:
1415
. Fixed improbably integer overflow while parsing really large (or small)

ext/spl/php_spl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,10 @@ PHP_FUNCTION(spl_autoload_unregister)
585585

586586
if (fcc.function_handler && zend_string_equals_literal(
587587
fcc.function_handler->common.function_name, "spl_autoload_call")) {
588-
/* Don't destroy the hash table, as we might be iterating over it right now. */
589-
zend_hash_clean(spl_autoload_functions);
588+
if (spl_autoload_functions) {
589+
/* Don't destroy the hash table, as we might be iterating over it right now. */
590+
zend_hash_clean(spl_autoload_functions);
591+
}
590592
RETURN_TRUE;
591593
}
592594

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
spl_autoload_unregister("spl_autoload_call") without registrations
3+
--FILE--
4+
<?php
5+
var_dump(spl_autoload_unregister("spl_autoload_call"));
6+
?>
7+
Done
8+
--EXPECT--
9+
bool(true)
10+
Done

0 commit comments

Comments
 (0)