]> granicus.if.org Git - php/commitdiff
Fix a possible segfault (Thanks to Sebastian for catching it)
authorSascha Schumann <sas@php.net>
Fri, 3 Aug 2001 09:36:14 +0000 (09:36 +0000)
committerSascha Schumann <sas@php.net>
Fri, 3 Aug 2001 09:36:14 +0000 (09:36 +0000)
ext/standard/fsock.c

index 8e3eac0828c1e410b65df658accb825ab9d3c092..f9182be6132e7d8b2907ce14058c9d30f11a7539 100644 (file)
@@ -89,9 +89,16 @@ extern int le_fp;
                efree(key);                             \
        }
 
-#define SEARCHCR() do {                                                                                        \
-       for (p = READPTR(sock), pe = p + MIN(TOREAD(sock), maxlen); \
-                       *p != '\n'; ) if (++p >= pe) { p = NULL; break; }       \
+#define SEARCHCR() do {                                                                                                \
+       if (TOREAD(sock)) {                                                                                             \
+               for (p = READPTR(sock), pe = p + MIN(TOREAD(sock), maxlen);     \
+                               *p != '\n'; )                                                                           \
+                       if (++p >= pe) {                                                                                \
+                               p = NULL;                                                                                       \
+                               break;                                                                                          \
+                       }                                                                                                               \
+       } else                                                                                                                  \
+               p = NULL;                                                                                                       \
 } while (0)
 
 #ifdef PHP_WIN32