diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-11-27 17:00:12 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-11-27 17:00:12 +0100 |
commit | e5aae358554d09dff75b81970d2ab3f03968fe09 (patch) | |
tree | bdbff587b42757ac589688f740671310d77ccdee /ext/opcache | |
parent | 4f3cf983dcdab2e5443d621894f1c52c1847749e (diff) | |
download | php-git-e5aae358554d09dff75b81970d2ab3f03968fe09.tar.gz |
Handle exceptions during SCCP function evaluation
Easier to handle them than to ensure they can't happen in the
first place.
Diffstat (limited to 'ext/opcache')
-rw-r--r-- | ext/opcache/Optimizer/sccp.c | 9 | ||||
-rw-r--r-- | ext/opcache/tests/opt/sccp_exception.phpt | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index d0dffc275d..1c4330717b 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -26,6 +26,7 @@ #include "Optimizer/scdf.h" #include "Optimizer/zend_dump.h" #include "ext/standard/php_string.h" +#include "zend_exceptions.h" /* This implements sparse conditional constant propagation (SCCP) based on the SCDF framework. The * used value lattice is defined as follows: @@ -1040,12 +1041,20 @@ static inline int ct_eval_func_call( for (i = 0; i < num_args; i++) { ZVAL_COPY(EX_VAR_NUM(i), args[i]); } + ZVAL_NULL(result); func->internal_function.handler(execute_data, result); for (i = 0; i < num_args; i++) { zval_ptr_dtor_nogc(EX_VAR_NUM(i)); } efree(execute_data); EG(current_execute_data) = prev_execute_data; + + if (EG(exception)) { + zval_ptr_dtor(result); + zend_clear_exception(); + return FAILURE; + } + return SUCCESS; } diff --git a/ext/opcache/tests/opt/sccp_exception.phpt b/ext/opcache/tests/opt/sccp_exception.phpt new file mode 100644 index 0000000000..685dfe1340 --- /dev/null +++ b/ext/opcache/tests/opt/sccp_exception.phpt @@ -0,0 +1,12 @@ +--TEST-- +Exception thrown during SCCP evaluation +--FILE-- +<?php +var_dump(version_compare('1.2', '2.1', '??')); +?> +--EXPECTF-- +Fatal error: Uncaught ValueError: version_compare(): Argument #3 ($operator) must be a valid comparison operator in %s:%d +Stack trace: +#0 %s(%d): version_compare('1.2', '2.1', '??') +#1 {main} + thrown in %s on line %d |