diff options
| author | Felipe Pena <felipe@php.net> | 2009-05-10 20:15:39 +0000 |
|---|---|---|
| committer | Felipe Pena <felipe@php.net> | 2009-05-10 20:15:39 +0000 |
| commit | 71aa2ea29b44848d0861e7cc8da73b723186cb83 (patch) | |
| tree | 8421f69ff137d12a6c9fe3c75b84c574811f66f1 | |
| parent | fbb11e58c51c9bd8127ab9dc19e6088efc4529fe (diff) | |
| download | php-git-71aa2ea29b44848d0861e7cc8da73b723186cb83.tar.gz | |
- Fixed bug #48227 (NumberFormatter::format leaks memory)
| -rwxr-xr-x | ext/intl/formatter/formatter_format.c | 6 | ||||
| -rw-r--r-- | ext/intl/tests/bug48227.phpt | 19 |
2 files changed, 20 insertions, 5 deletions
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-- +<?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" |
