Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ PHP NEWS
and later. (Graham Campbell)
. Fixed Locale::lookup() and locale_lookup() to return NULL instead of the
fallback locale when a language tag cannot be canonicalized. (Weilin Du)
. Fixed memory leaks when calling Collator::__construct() or
Spoofchecker::__construct() twice. (Weilin Du)

- mysqli:
. Fix stmt->query leak in mysqli_execute_query() validation errors.
Expand Down
4 changes: 4 additions & 0 deletions ext/intl/collator/collator_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro

INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
COLLATOR_METHOD_FETCH_OBJECT;
if (co->ucoll) {
zend_throw_error(NULL, "Collator object is already constructed");
return FAILURE;
}

if(locale_len == 0) {
locale = (char *)intl_locale_get_default();
Expand Down
8 changes: 6 additions & 2 deletions ext/intl/spoofchecker/spoofchecker_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ PHP_METHOD(Spoofchecker, __construct)

ZEND_PARSE_PARAMETERS_NONE();

zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);

SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK;
if (co->uspoof) {
zend_throw_error(NULL, "Spoofchecker object is already constructed");
RETURN_THROWS();
}

zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);

co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
INTL_METHOD_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");
Expand Down
16 changes: 16 additions & 0 deletions ext/intl/tests/collator_double_ctor.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Collator double construction should not be allowed
--EXTENSIONS--
intl
--FILE--
<?php
$collator = new Collator('en_US');

try {
$collator->__construct('en_US');
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Collator object is already constructed
18 changes: 18 additions & 0 deletions ext/intl/tests/spoofchecker_double_ctor.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Spoofchecker double construction should not be allowed
--EXTENSIONS--
intl
--SKIPIF--
<?php if (!class_exists("Spoofchecker")) print "skip"; ?>
--FILE--
<?php
$checker = new Spoofchecker();

try {
$checker->__construct();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Spoofchecker object is already constructed
Loading