Skip to content

Commit a20aeb1

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: ext/Intl: Fix IntlListFormatter double construction leak (php#22394)
2 parents 52cc923 + aa21625 commit a20aeb1

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

ext/intl/listformatter/listformatter_class.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ PHP_METHOD(IntlListFormatter, __construct)
7474
Z_PARAM_LONG(width)
7575
ZEND_PARSE_PARAMETERS_END();
7676

77+
if (LISTFORMATTER_OBJECT(obj)) {
78+
zend_throw_error(NULL, "IntlListFormatter object is already constructed");
79+
RETURN_THROWS();
80+
}
81+
7782
if(locale_len == 0) {
7883
locale = (char *)intl_locale_get_default();
7984
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
IntlListFormatter double construction should not be allowed
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
$formatter = new IntlListFormatter('en_US');
8+
9+
try {
10+
$formatter->__construct('en_US');
11+
} catch (Error $e) {
12+
echo $e->getMessage(), "\n";
13+
}
14+
?>
15+
--EXPECT--
16+
IntlListFormatter object is already constructed

0 commit comments

Comments
 (0)