From: Felipe Pena Date: Sun, 10 May 2009 20:15:39 +0000 (+0000) Subject: - Fixed bug #48227 (NumberFormatter::format leaks memory) X-Git-Tag: php-5.4.0alpha1~191^2~3705 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71aa2ea29b44848d0861e7cc8da73b723186cb83;p=php - Fixed bug #48227 (NumberFormatter::format leaks memory) --- diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c index 1fe9fd6a45..9d6fe5729a 100755 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.c @@ -53,11 +53,7 @@ PHP_FUNCTION( numfmt_format ) if(type == FORMAT_TYPE_DEFAULT) { if(Z_TYPE_PP(number) == IS_STRING) { - SEPARATE_ZVAL_IF_NOT_REF(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); - } + convert_scalar_to_number_ex(number); } if(Z_TYPE_PP(number) == IS_LONG) { diff --git a/ext/intl/tests/bug48227.phpt b/ext/intl/tests/bug48227.phpt new file mode 100644 index 0000000000..8f633c7375 --- /dev/null +++ b/ext/intl/tests/bug48227.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #48227 (NumberFormatter::format leaks memory) +--FILE-- +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"