mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fixed GH-19261: msgfmt_parse_message leaks on message format failure.
close GH-19262
This commit is contained in:
4
NEWS
4
NEWS
@@ -14,6 +14,10 @@ PHP NEWS
|
||||
- Hash:
|
||||
. Fix crash on clone failure. (nielsdos)
|
||||
|
||||
- Intl:
|
||||
. Fixed GH-19261: msgfmt_parse_message leaks on message creation failure.
|
||||
(David Carlier)
|
||||
|
||||
- LDAP:
|
||||
. Fixed bug GH-18529 (additional inheriting of TLS int options).
|
||||
(Jakub Zelenka)
|
||||
|
||||
@@ -127,10 +127,11 @@ PHP_FUNCTION( msgfmt_parse_message )
|
||||
if(spattern && spattern_len) {
|
||||
efree(spattern);
|
||||
}
|
||||
INTL_METHOD_CHECK_STATUS(mfo, "Creating message formatter failed");
|
||||
INTL_METHOD_CHECK_STATUS_OR_GOTO(mfo, "Creating message formatter failed", clean);
|
||||
|
||||
msgfmt_do_parse(mfo, source, src_len, return_value);
|
||||
|
||||
clean:
|
||||
/* drop the temporary formatter */
|
||||
msgformat_data_free(&mfo->mf_data);
|
||||
}
|
||||
|
||||
28
ext/intl/tests/gh19261.phpt
Normal file
28
ext/intl/tests/gh19261.phpt
Normal file
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
MessageFormatter::parseMessage() with invalid locale
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--CREDITS--
|
||||
girgias@php.net
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$locale = 'root';
|
||||
$fmt = '{0,whatever} would not work!';
|
||||
|
||||
$str = 'failing';
|
||||
|
||||
$m = MessageFormatter::parseMessage($locale, $fmt, $str);
|
||||
var_dump($m);
|
||||
var_dump(intl_get_error_message());
|
||||
|
||||
$m = msgfmt_parse_message($locale, $fmt, $str);
|
||||
var_dump($m);
|
||||
var_dump(intl_get_error_message());
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(59) "Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
bool(false)
|
||||
string(59) "Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR"
|
||||
Reference in New Issue
Block a user