diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index 430d5a741115f..8149f34c75e82 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -448,6 +448,10 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, * as a result of that. */ str = zval_get_tmp_string(elem, &tmp_str); + if (!str || !ZSTR_LEN(str)) { + EG(exception) = NULL; + return; + } UnicodeString *text = new UnicodeString(); intl_stringFromChar(*text, diff --git a/ext/intl/tests/gh16814.phpt b/ext/intl/tests/gh16814.phpt new file mode 100644 index 0000000000000..d45c91bf8719c --- /dev/null +++ b/ext/intl/tests/gh16814.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-16814 (MessageFormatter::format throws error on unused parameter) +--EXTENSIONS-- +intl +--FILE-- +format(['payed' => new DateTimeImmutable()]); +echo "OK"; +?> +--EXPECT-- +OK