Skip to content

Commit 7c1bc91

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 571a3bf + 2114867 commit 7c1bc91

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
A "non well formed" notice converted to exception should result in a ZPP failure
3+
--FILE--
4+
<?php
5+
6+
set_error_handler(function($_, $msg) {
7+
throw new Exception($msg);
8+
}, E_NOTICE);
9+
10+
try {
11+
wordwrap("foo", "123foo", "");
12+
} catch (Exception $e) {
13+
echo $e, "\n";
14+
}
15+
16+
?>
17+
--EXPECTF--
18+
Exception: A non well formed numeric value encountered in %s:%d
19+
Stack trace:
20+
#0 [internal function]: {closure}(%s)
21+
#1 %s(%d): wordwrap('foo', '123foo', '')
22+
#2 {main}

Zend/zend_API.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest)
339339
return 0;
340340
}
341341
}
342+
if (UNEXPECTED(EG(exception))) {
343+
return 0;
344+
}
342345
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
343346
*dest = 0;
344347
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
@@ -374,6 +377,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /
374377
return 0;
375378
}
376379
}
380+
if (UNEXPECTED(EG(exception))) {
381+
return 0;
382+
}
377383
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
378384
*dest = 0.0;
379385
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {

Zend/zend_execute.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,12 @@ ZEND_API ZEND_COLD void zend_verify_arg_error(
728728
const char *fname, *fsep, *fclass;
729729
const char *need_msg, *need_kind, *need_or_null, *given_msg, *given_kind;
730730

731+
if (EG(exception)) {
732+
/* The type verification itself might have already thrown an exception
733+
* through a promoted warning. */
734+
return;
735+
}
736+
731737
if (value) {
732738
zend_verify_type_error_common(
733739
zf, arg_info, ce, value,

Zend/zend_operators.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,6 +2961,9 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t
29612961
}
29622962
if (allow_errors == -1) {
29632963
zend_error(E_NOTICE, "A non well formed numeric value encountered");
2964+
if (EG(exception)) {
2965+
return 0;
2966+
}
29642967
}
29652968
}
29662969

Zend/zend_vm_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5075,7 +5075,7 @@ ZEND_VM_HOT_HANDLER(63, ZEND_RECV, NUM, UNUSED, CACHE_SLOT)
50755075
zval *param = EX_VAR(opline->result.var);
50765076

50775077
SAVE_OPLINE();
5078-
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)) || EG(exception))) {
5078+
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)))) {
50795079
HANDLE_EXCEPTION();
50805080
}
50815081
}
@@ -5121,7 +5121,7 @@ ZEND_VM_HOT_HANDLER(64, ZEND_RECV_INIT, NUM, CONST, CACHE_SLOT)
51215121

51225122
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
51235123
SAVE_OPLINE();
5124-
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)) || EG(exception))) {
5124+
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)))) {
51255125
HANDLE_EXCEPTION();
51265126
}
51275127
}

Zend/zend_vm_execute.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,7 +2977,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_INIT_SPEC_CON
29772977

29782978
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
29792979
SAVE_OPLINE();
2980-
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)) || EG(exception))) {
2980+
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)))) {
29812981
HANDLE_EXCEPTION();
29822982
}
29832983
}
@@ -3055,7 +3055,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_SPEC_UNUSED_H
30553055
zval *param = EX_VAR(opline->result.var);
30563056

30573057
SAVE_OPLINE();
3058-
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)) || EG(exception))) {
3058+
if (UNEXPECTED(!zend_verify_recv_arg_type(EX(func), arg_num, param, CACHE_ADDR(opline->extended_value)))) {
30593059
HANDLE_EXCEPTION();
30603060
}
30613061
}

0 commit comments

Comments
 (0)