Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PHP NEWS
non-printable characters in string literals). (nielsdos, WangYihang)
. Add support for backtraces for fatal errors. (enorris)
. Fixed bug GH-17442 (Engine UAF with reference assign and dtor). (nielsdos)
. Improved error message of UnhandledMatchError for
zend.exception_string_param_max_len=0. (timwolla)

- Curl:
. Added curl_multi_get_handles(). (timwolla)
Expand Down
42 changes: 42 additions & 0 deletions Zend/tests/match/048.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
Match expression error messages (exception_string_param_max_len=0)
--INI--
zend.exception_string_param_max_len=0
--FILE--
<?php

class Beep {}

function test(mixed $var) {
try {
match($var) {};
} catch (UnhandledMatchError $e) {
print $e->getMessage() . PHP_EOL;
}
}

test(null);
test(1);
test(5.5);
test(5.0);
test("foo");
test(true);
test(false);
test([1, 2, 3]);
test(new Beep());
// Testing long strings.
test(str_repeat('e', 100));
test(str_repeat("e\n", 100));
?>
--EXPECT--
Unhandled match case NULL
Unhandled match case 1
Unhandled match case 5.5
Unhandled match case 5.0
Unhandled match case of type string
Unhandled match case true
Unhandled match case false
Unhandled match case of type array
Unhandled match case of type Beep
Unhandled match case of type string
Unhandled match case of type string
4 changes: 3 additions & 1 deletion Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,12 @@ ZEND_COLD zend_never_inline void zend_magic_get_property_type_inconsistency_erro

ZEND_COLD void zend_match_unhandled_error(const zval *value)
{
zend_long max_len = EG(exception_string_param_max_len);
smart_str msg = {0};
if (
EG(exception_ignore_args)
|| smart_str_append_zval(&msg, value, EG(exception_string_param_max_len)) != SUCCESS
|| (Z_TYPE_P(value) == IS_STRING && max_len == 0)
|| smart_str_append_zval(&msg, value, max_len) != SUCCESS
) {
smart_str_appendl(&msg, "of type ", sizeof("of type ")-1);
smart_str_appends(&msg, zend_zval_type_name(value));
Expand Down