Skip to content

Commit 49e4e64

Browse files
committed
Fix GH-16414: zend_test.observer.observe_function_names may segfault
Unless `zend_test.observer.enabled` is on, we must not add observer handlers, so we let the INI modify handler fail early. Proper fix suggested by @bwoebi.
1 parent 5955ce8 commit 49e4e64

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ext/zend_test/observer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ static ZEND_INI_MH(zend_test_observer_OnUpdateCommaList)
304304
zend_array **p = (zend_array **) ZEND_INI_GET_ADDR();
305305
zend_string *funcname;
306306
zend_function *func;
307+
if (!ZT_G(observer_enabled)) {
308+
return FAILURE;
309+
}
307310
if (stage != PHP_INI_STAGE_STARTUP && stage != PHP_INI_STAGE_ACTIVATE && stage != PHP_INI_STAGE_DEACTIVATE && stage != PHP_INI_STAGE_SHUTDOWN) {
308311
ZEND_HASH_FOREACH_STR_KEY(*p, funcname) {
309312
if ((func = zend_hash_find_ptr(EG(function_table), funcname))) {

ext/zend_test/tests/gh16414.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-16414 (zend_test.observer.observe_function_names may segfault)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
function bar() {}
8+
var_dump(ini_set("zend_test.observer.observe_function_names", "bar"));
9+
?>
10+
--EXPECT--
11+
bool(false)

0 commit comments

Comments
 (0)