Skip to content

Commit 898c945

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: intl: Fix leak in umsg_format_helper()
2 parents 4f3c28a + b81f770 commit 898c945

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ext/intl/msgformat/msgformat_helpers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
455455
char *message;
456456
spprintf(&message, 0, "Invalid UTF-8 data in string argument: "
457457
"'%s'", ZSTR_VAL(str));
458+
zend_tmp_string_release(tmp_str);
458459
intl_errors_set(&err, err.code, message);
459460
efree(message);
460461
delete text;

ext/intl/tests/msgfmt_format_error4.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,22 @@ try {
2525
var_dump($e::class === 'IntlException');
2626
var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage());
2727
}
28+
29+
try {
30+
var_dump($mf->format(array("foo" => new class {
31+
function __toString(): string {
32+
return str_repeat("\x80", random_int(1, 1));
33+
}
34+
})));
35+
} catch (Throwable $e) {
36+
var_dump($e::class === 'IntlException');
37+
var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage());
38+
}
2839
?>
2940
--EXPECT--
3041
bool(true)
3142
bool(true)
3243
bool(true)
3344
bool(true)
45+
bool(true)
46+
bool(true)

0 commit comments

Comments
 (0)