diff options
| author | Ben Fuhrmannek | 2022-01-06 21:22:50 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2022-01-06 21:22:50 +0100 |
| commit | 4b5afd0148cef6c845a37aff68e1fbac8f5653d7 (patch) | |
| tree | ad4a4832d3ddaa33e336216a3363107acf02c2ed /src/sp_disabled_functions.c | |
| parent | 94d3124c3972ee950a40dad72fe1b4bcf16db2c4 (diff) | |
prevent double checks and fixed segfault on return value access
Diffstat (limited to '')
| -rw-r--r-- | src/sp_disabled_functions.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 1d9c6c7..c0c642b 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -400,7 +400,6 @@ static void should_drop_on_ret(const zval* return_value, | |||
| 400 | bool match_type = false, match_value = false; | 400 | bool match_type = false, match_value = false; |
| 401 | 401 | ||
| 402 | while (config) { | 402 | while (config) { |
| 403 | const zend_string* ret_value_str = NULL; | ||
| 404 | sp_disabled_function const* const config_node = | 403 | sp_disabled_function const* const config_node = |
| 405 | (sp_disabled_function*)(config->data); | 404 | (sp_disabled_function*)(config->data); |
| 406 | 405 | ||
| @@ -444,13 +443,18 @@ static void should_drop_on_ret(const zval* return_value, | |||
| 444 | } | 443 | } |
| 445 | } | 444 | } |
| 446 | 445 | ||
| 447 | ret_value_str = sp_zval_to_zend_string(return_value); | 446 | const zend_string* ret_value_str = NULL; |
| 447 | sp_php_type ret_type = SP_PHP_TYPE_NULL; | ||
| 448 | |||
| 449 | if (return_value) { | ||
| 450 | ret_value_str = sp_zval_to_zend_string(return_value); | ||
| 451 | ret_type = Z_TYPE_P(return_value); | ||
| 452 | } | ||
| 448 | 453 | ||
| 449 | match_type = (config_node->ret_type) && | 454 | match_type = (config_node->ret_type) && |
| 450 | (config_node->ret_type == Z_TYPE_P(return_value)); | 455 | (config_node->ret_type == ret_type); |
| 451 | match_value = (config_node->ret || config_node->r_ret) && | 456 | match_value = return_value && (config_node->ret || config_node->r_ret) && |
| 452 | (true == sp_match_value(ret_value_str, config_node->ret, | 457 | (true == sp_match_value(ret_value_str, config_node->ret, config_node->r_ret)); |
| 453 | config_node->r_ret)); | ||
| 454 | 458 | ||
| 455 | if (true == match_type || true == match_value) { | 459 | if (true == match_type || true == match_value) { |
| 456 | if (true == config_node->allow) { | 460 | if (true == config_node->allow) { |
