]> granicus.if.org Git - php/commitdiff
fix #38721 (date_parse() invalid read)
authorAntony Dovgal <tony2001@php.net>
Fri, 8 Sep 2006 20:22:23 +0000 (20:22 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 8 Sep 2006 20:22:23 +0000 (20:22 +0000)
ext/date/lib/parse_date.c

index 0ebf56c4e6a29fec0c7752e350557b8836bc854d..4f588f35076a1320998aae1f2f9ae7582cc4acfc 100644 (file)
@@ -22140,13 +22140,15 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
        in.errors->error_count = 0;
        in.errors->error_messages = NULL;
 
-       while (isspace(*s) && s < e) {
-               s++;
-       }
-       while (isspace(*e) && e > s) {
-               e--;
-       }
-       if (e - s < 1) {
+       if (len > 0) {
+               while (isspace(*s) && s < e) {
+                       s++;
+               }
+               while (isspace(*e) && e > s) {
+                       e--;
+               }
+       }  
+       if (e - s < 1){
                in.time = timelib_time_ctor();
                add_error(&in, "Empty string");
                if (errors) {