Commit:    2827324c7cc4f3a28ad66cd2a3724165abac4941
Author:    Sherif Ramadan <theanomaly...@gmail.com>         Thu, 19 Apr 2012 
04:44:43 -0400
Parents:   4650b2164b641ba3fd9d733e8cc82e386aa98772
Branches:  PHP-5.3

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=2827324c7cc4f3a28ad66cd2a3724165abac4941

Log:
Bug#59597 NumberFormatter::parse() with TYPE_INT64 results in a 32 bit integer

Bugs:
https://bugs.php.net/59597

Changed paths:
  M  ext/intl/formatter/formatter_parse.c
  A  ext/intl/tests/bug59597.phpt


Diff:
diff --git a/ext/intl/formatter/formatter_parse.c 
b/ext/intl/formatter/formatter_parse.c
index cbdde85..6f3a3a1 100755
--- a/ext/intl/formatter/formatter_parse.c
+++ b/ext/intl/formatter/formatter_parse.c
@@ -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:
diff --git a/ext/intl/tests/bug59597.phpt b/ext/intl/tests/bug59597.phpt
new file mode 100644
index 0000000..54c9b6d
--- /dev/null
+++ b/ext/intl/tests/bug59597.phpt
@@ -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)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to