From f306943799b185d5e332b3ae7eefc61f1a312bf0 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 10 May 2009 20:17:22 +0000 Subject: [PATCH] - Fixed bug #48227 (NumberFormatter::format leaks memory) --- NEWS | 1 + ext/intl/formatter/formatter_format.c | 6 +----- ext/intl/tests/bug48227.phpt | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 ext/intl/tests/bug48227.phpt diff --git a/NEWS b/NEWS index ab6255f71e..93d51b2659 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ PHP NEWS - Disabled SQLite3::loadExtension for threaded SAPIs. (Scott) +- Fixed bug #48227 (NumberFormatter::format leaks memory). (Felipe) 07 May 2009, PHP 5.3.0 RC 2 - Upgraded bundled sqlite to version 3.6.13. (Ilia) diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c index 47e266ff46..ce1c941e19 100755 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.c @@ -54,11 +54,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" -- 2.50.1