mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
- Fixed bug #48227 (NumberFormatter::format leaks memory)
This commit is contained in:
parent
fbb11e58c5
commit
71aa2ea29b
2 changed files with 20 additions and 5 deletions
|
@ -53,11 +53,7 @@ PHP_FUNCTION( numfmt_format )
|
||||||
|
|
||||||
if(type == FORMAT_TYPE_DEFAULT) {
|
if(type == FORMAT_TYPE_DEFAULT) {
|
||||||
if(Z_TYPE_PP(number) == IS_STRING) {
|
if(Z_TYPE_PP(number) == IS_STRING) {
|
||||||
SEPARATE_ZVAL_IF_NOT_REF(number);
|
convert_scalar_to_number_ex(number);
|
||||||
if ((Z_TYPE_PP(number)=is_numeric_string(Z_STRVAL_PP(number), Z_STRLEN_PP(number),
|
|
||||||
&Z_LVAL_PP(number), &Z_DVAL_PP(number), 1)) == 0) {
|
|
||||||
ZVAL_LONG(*number, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Z_TYPE_PP(number) == IS_LONG) {
|
if(Z_TYPE_PP(number) == IS_LONG) {
|
||||||
|
|
19
ext/intl/tests/bug48227.phpt
Normal file
19
ext/intl/tests/bug48227.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #48227 (NumberFormatter::format leaks memory)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$x = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
|
||||||
|
var_dump($x->format(''));
|
||||||
|
var_dump($x->format(1));
|
||||||
|
var_dump($x->format(NULL));
|
||||||
|
var_dump($x->format($x));
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(1) "0"
|
||||||
|
string(1) "1"
|
||||||
|
string(1) "0"
|
||||||
|
|
||||||
|
Notice: Object of class NumberFormatter could not be converted to int in %s on line %d
|
||||||
|
string(1) "1"
|
Loading…
Add table
Add a link
Reference in a new issue