From c853c3fcc7ba2efbf78ef80b46dddda57d132510 Mon Sep 17 00:00:00 2001 From: Thibault "bui" Koechlin Date: Fri, 26 Jan 2018 18:35:40 +0100 Subject: Fix a segfault in `get_local_var` (#138) This commit fixes a segfault where 'get_local_var' would fail if no functions where called yet (`symtable` will be NULL)--- src/sp_var_value.c | 5 +++++ src/tests/disabled_function_local_var_crash.phpt | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/tests/disabled_function_local_var_crash.phpt diff --git a/src/sp_var_value.c b/src/sp_var_value.c index a3eed3e..05598bf 100644 --- a/src/sp_var_value.c +++ b/src/sp_var_value.c @@ -27,6 +27,11 @@ static zval *get_local_var(zend_execute_data *ed, const char *var_name) { EG(current_execute_data) = current; zend_array *symtable = zend_rebuild_symbol_table(); + if (UNEXPECTED(symtable == NULL)) { + EG(current_execute_data) = orig_execute_data; + return NULL; + } + ZEND_HASH_FOREACH_STR_KEY_VAL(symtable, key, value) { if (0 == strcmp(var_name, key->val)) { if (Z_TYPE_P(value) == IS_INDIRECT) { diff --git a/src/tests/disabled_function_local_var_crash.phpt b/src/tests/disabled_function_local_var_crash.phpt new file mode 100644 index 0000000..8dec946 --- /dev/null +++ b/src/tests/disabled_function_local_var_crash.phpt @@ -0,0 +1,18 @@ +--TEST-- +Disable functions - match on a local variable +--SKIPIF-- + +--INI-- +sp.configuration_file={PWD}/config/disabled_function_local_var.ini +--FILE-- + +--EXPECTF-- +2 +test + -- cgit v1.3