Skip to content

Commit f593019

Browse files
committed
Prevent ResourceBundle double-construction
1 parent 6b55425 commit f593019

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ext/intl/resourcebundle/resourcebundle_class.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
9393
return FAILURE;
9494
}
9595

96+
if (rb->me) {
97+
zend_throw_error(NULL, "ResourceBundle object is already constructed");
98+
return FAILURE;
99+
}
100+
96101
INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
97102

98103
if (locale == NULL) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
ResourceBundle double construction should not be allowed
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
include "resourcebundle.inc";
9+
$r = new ResourceBundle('en_US', BUNDLE);
10+
try {
11+
$r->__construct('en_US', BUNDLE);
12+
} catch (Error $e) {
13+
echo $e->getMessage(), "\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
ResourceBundle object is already constructed

0 commit comments

Comments
 (0)