Skip to content

Commit a775428

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Add test for bug #76942 Fixed Bug #76942 U_ARGUMENT_TYPE_MISMATCH
2 parents fde2ae3 + c2a956d commit a775428

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

ext/intl/msgformat/msgformat_helpers.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extern "C" {
4646

4747
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
4848
#define HAS_MESSAGE_PATTERN 1
49+
#define HAS_MISALLOCATE_MEMORY_BUG 1
4950
#endif
5051

5152
U_NAMESPACE_BEGIN
@@ -334,6 +335,7 @@ static void umsg_set_timezone(MessageFormatter_object *mfo,
334335
return; /* already done */
335336
}
336337

338+
#ifdef HAS_MISALLOCATE_MEMORY_BUG
337339
/* There is a bug in ICU which prevents MessageFormatter::getFormats()
338340
to handle more than 10 formats correctly. The enumerator could be
339341
used to walk through the present formatters using getFormat(), which
@@ -351,6 +353,7 @@ static void umsg_set_timezone(MessageFormatter_object *mfo,
351353
if (count > 10) {
352354
return;
353355
}
356+
#endif
354357

355358
formats = mf->getFormats(count);
356359

ext/intl/tests/bug74484_MessageFormatter.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Bug #74484 MessageFormatter::formatMessage memory corruption with 11+ named plac
44
<?php
55
if (!extension_loaded('intl'))
66
die('skip intl extension not enabled');
7+
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
8+
die('skip for ICU 4.8+');
79
?>
810
--FILE--
911
<?php
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #76942 U_ARGUMENT_TYPE_MISMATCH
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('intl'))
6+
die('skip intl extension not enabled');
7+
?>
8+
--FILE--
9+
<?php
10+
11+
$locale = 'nl';
12+
$message = '{0,number,#,###.##} MB';
13+
$vars = [
14+
7.1234
15+
];
16+
17+
$formatter = new MessageFormatter($locale, $message);
18+
if (!$formatter) {
19+
throw new Exception(intl_get_error_message(), intl_get_error_code());
20+
}
21+
22+
$result = $formatter->format($vars);
23+
if ($result === false) {
24+
throw new Exception($formatter->getErrorMessage(), $formatter->getErrorCode());
25+
}
26+
27+
var_dump($result);
28+
29+
?>
30+
==DONE==
31+
--EXPECT--
32+
string(7) "7,12 MB"
33+
==DONE==

0 commit comments

Comments
 (0)