diff options
-rw-r--r-- | ext/date/lib/parse_date.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 740a33c385..dececa88c6 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -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) { |