Skip to content

Commit 46428a8

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Handle exceptions during SCCP function evaluation
2 parents 3459099 + e5aae35 commit 46428a8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Optimizer/scdf.h"
2727
#include "Optimizer/zend_dump.h"
2828
#include "ext/standard/php_string.h"
29+
#include "zend_exceptions.h"
2930

3031
/* This implements sparse conditional constant propagation (SCCP) based on the SCDF framework. The
3132
* used value lattice is defined as follows:
@@ -1040,12 +1041,20 @@ static inline int ct_eval_func_call(
10401041
for (i = 0; i < num_args; i++) {
10411042
ZVAL_COPY(EX_VAR_NUM(i), args[i]);
10421043
}
1044+
ZVAL_NULL(result);
10431045
func->internal_function.handler(execute_data, result);
10441046
for (i = 0; i < num_args; i++) {
10451047
zval_ptr_dtor_nogc(EX_VAR_NUM(i));
10461048
}
10471049
efree(execute_data);
10481050
EG(current_execute_data) = prev_execute_data;
1051+
1052+
if (EG(exception)) {
1053+
zval_ptr_dtor(result);
1054+
zend_clear_exception();
1055+
return FAILURE;
1056+
}
1057+
10491058
return SUCCESS;
10501059
}
10511060

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Exception thrown during SCCP evaluation
3+
--FILE--
4+
<?php
5+
var_dump(version_compare('1.2', '2.1', '??'));
6+
?>
7+
--EXPECTF--
8+
Fatal error: Uncaught ValueError: version_compare(): Argument #3 ($operator) must be a valid comparison operator in %s:%d
9+
Stack trace:
10+
#0 %s(%d): version_compare('1.2', '2.1', '??')
11+
#1 {main}
12+
thrown in %s on line %d

0 commit comments

Comments
 (0)