]> granicus.if.org Git - php/commitdiff
Fixed bug #28800 (strings beginning with "inf" improperly converted).
authorIlia Alshanetsky <iliaa@php.net>
Fri, 16 Jul 2004 02:02:09 +0000 (02:02 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 16 Jul 2004 02:02:09 +0000 (02:02 +0000)
Zend/zend_operators.h
tests/lang/bug28800.phpt [new file with mode: 0644]

index c6182ff6b6504557dfdb3620ffe3352be17d10c3..b6b845ae76b958bb33bbbaa769ea0e4f63fd5443 100644 (file)
@@ -87,6 +87,8 @@ static inline zend_bool is_numeric_string(char *str, int length, long *lval, dou
                                *lval = local_lval;
                        }
                        return IS_LONG;
+               } else if (end_ptr_long == str && *end_ptr_long != '\0') { /* ignore partial string matches */
+                       return 0;
                }
        } else {
                end_ptr_long=NULL;
diff --git a/tests/lang/bug28800.phpt b/tests/lang/bug28800.phpt
new file mode 100644 (file)
index 0000000..f81ad7f
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #28800 (Incorrect string to number conversion for strings starting with 'inf')
+--FILE--
+<?php
+       $strings = array('into', 'info', 'inf', 'infinity', 'infin', 'inflammable');
+       foreach ($strings as $v) {
+               echo ($v+0)."\n";
+       }
+?>
+--EXPECT--
+0
+0
+0
+0
+0
+0
+