Skip to content

Commit b81f770

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: intl: Fix leak in umsg_format_helper()
2 parents 006788b + 10bbd95 commit b81f770

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ PHP NEWS
1919
. Fixed bug GH-20631 (Integer underflow in exif HEIF parsing
2020
when pos.size < 2). (Oblivionsage)
2121

22+
- Intl:
23+
. Fix leak in umsg_format_helper(). (ndossche)
24+
2225
- LDAP:
2326
. Fix memory leak in ldap_set_options(). (ndossche)
2427

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)