diff --git a/NEWS b/NEWS index c80e0a60bb3..23ff95cee78 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,9 @@ PHP NEWS - GD: . Fixed bug GH-20622 (imagestring/imagestringup overflow). (David Carlier) +- Intl: + . Fix leak in umsg_format_helper(). (ndossche) + - LDAP: . Fix memory leak in ldap_set_options(). (ndossche) diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index fbd85b857f3..58e2a96bf23 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -457,6 +457,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, char *message; spprintf(&message, 0, "Invalid UTF-8 data in string argument: " "'%s'", ZSTR_VAL(str)); + zend_tmp_string_release(tmp_str); intl_errors_set(&err, err.code, message, 1); efree(message); delete text; diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt index a6f59127230..b8ff3a0cd47 100644 --- a/ext/intl/tests/msgfmt_format_error4.phpt +++ b/ext/intl/tests/msgfmt_format_error4.phpt @@ -14,6 +14,12 @@ $mf = new MessageFormatter('en_US', $fmt); var_dump($mf->format(array("foo" => 7, "\x80" => "bar"))); var_dump($mf->format(array("foo" => "\x80"))); + +var_dump($mf->format(array("foo" => new class { + function __toString(): string { + return str_repeat("\x80", random_int(1, 1)); + } +}))); ?> --EXPECTF-- Warning: MessageFormatter::format(): Invalid UTF-8 data in argument key: '€' in %s on line %d @@ -21,3 +27,6 @@ bool(false) Warning: MessageFormatter::format(): Invalid UTF-8 data in string argument: '€' in %s on line %d bool(false) + +Warning: MessageFormatter::format(): Invalid UTF-8 data in string argument: '€' in %s on line %d +bool(false)