[PATCH] Small typo in zend_u_strtol
| From: | Matt W | Date: | Mon, 25 Sep 2006 14:26:52 +0000 |
| Subject: | [PATCH] Small typo in zend_u_strtol | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-25820@lists.php.net to get a copy of this message | ||
Hi,
Noticed this a couple months ago and never sent this simple thing. :-)
ERANGE is being triggered too soon because of the wrong variable, which
causes the following (in Unicode mode, of course) on 32-bit:
(int) '2147483640' // int(2147483647)
'2147483640' + 0) // float(2147483640)
Instead of the expected int(2147483640) in both cases.
Matt
Index: zend_strtol.c =================================================================== RCS file: /repository/ZendEngine2/zend_strtol.c,v retrieving revision 1.2 diff -u -r1.2 zend_strtol.c --- zend_strtol.c 21 Feb 2006 20:12:41 -0000 1.2 +++ zend_strtol.c 21 Sep 2006 08:49:24 -0000 @@ -103,7 +103,7 @@ for (acc = 0, any = 0;; c = *s++) { if ((val = u_digit(c, base)) < 0) break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + if (any < 0 || acc > cutoff || (acc == cutoff && val > cutlim)) any = -1; else { any = 1;
Index: zend_strtol.c =================================================================== RCS file: /repository/ZendEngine2/zend_strtol.c,v retrieving revision 1.2 diff -u -r1.2 zend_strtol.c --- zend_strtol.c 21 Feb 2006 20:12:41 -0000 1.2 +++ zend_strtol.c 21 Sep 2006 08:49:24 -0000 @@ -103,7 +103,7 @@ for (acc = 0, any = 0;; c = *s++) { if ((val = u_digit(c, base)) < 0) break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + if (any < 0 || acc > cutoff || (acc == cutoff && val > cutlim)) any = -1; else { any = 1;