- Fixed bug #48227 (NumberFormatter::format leaks memory)

This commit is contained in:
Felipe Pena 2009-05-10 20:15:39 +00:00
parent fbb11e58c5
commit 71aa2ea29b
2 changed files with 20 additions and 5 deletions

View file

@ -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) {

View 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"