]> granicus.if.org Git - php/commitdiff
Fix fgetcsv()'s null line handling.
authorMoriyoshi Koizumi <moriyoshi@php.net>
Tue, 23 Dec 2003 11:02:26 +0000 (11:02 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Tue, 23 Dec 2003 11:02:26 +0000 (11:02 +0000)
# Thanks Takeshi Nakamura for reporting this bug.

ext/standard/file.c

index 57790adafdb05e965ee6f05974f461f46d4c9a09..d3bee95f9be2002622332d0a8c6188b25513dc8e 100644 (file)
@@ -2257,11 +2257,11 @@ PHP_FUNCTION(fgetcsv)
        re = e = buf + buf_len;
 
        /* strip leading spaces */
-       while (isspace((int)*(unsigned char *)s) && *s != delimiter) {
+       while (isspace((int)*(unsigned char *)s) && *s != delimiter && s < re) {
                s++;
        }
        /* strip trailing spaces */
-       while (isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
+       while (e >= s && isspace((int)*(unsigned char *)(--e)) && *e != delimiter);
        e++;
 
        array_init(return_value);