Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug#59597 NumberFormatter::parse() with TYPE_INT64 results in a 32 bit i... #61

Merged
merged 1 commit into from
Apr 19, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ext/intl/formatter/formatter_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ PHP_FUNCTION( numfmt_parse )
break;
case FORMAT_TYPE_INT64:
val64 = unum_parseInt64(FORMATTER_OBJECT(nfo), sstr, sstr_len, position_p, &INTL_DATA_ERROR_CODE(nfo));
if(val64 > LONG_MAX || val64 < -LONG_MAX) {
if(val64 > LONG_MAX || val64 < LONG_MIN) {
RETVAL_DOUBLE(val64);
} else {
val32 = (int32_t)val64;
RETVAL_LONG(val32);
RETVAL_LONG((long)val64);
}
break;
case FORMAT_TYPE_DOUBLE:
Expand Down
19 changes: 19 additions & 0 deletions ext/intl/tests/bug59597.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Bug#59597 NumberFormatter::parse() with TYPE_INT64 results in a 32 bit integer
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php

$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
$value = $formatter->parse('2147483647', \NumberFormatter::TYPE_INT32);
var_dump($value);

$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
$value = $formatter->parse('2147483650', \NumberFormatter::TYPE_INT64);
var_dump($value);

?>
--EXPECTF--
int(2147483647)
int(2147483650)