]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch_parse_date: Handle a NULL date string gracefully.
authorCarl Worth <cworth@cworth.org>
Mon, 19 Oct 2009 20:24:12 +0000 (13:24 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 19 Oct 2009 20:24:12 +0000 (13:24 -0700)
The obvious thing to do is to treat a missing date as the beginning
of time. Also, remove a useless cast from another return of 0.

date.c

diff --git a/date.c b/date.c
index 7fdbb7101cf4d447ec649f225ef512cbc5c84af8..3f337c962247f71c37ae217bc3fd18be959bbd5d 100644 (file)
--- a/date.c
+++ b/date.c
@@ -643,12 +643,15 @@ notmuch_parse_date (const char *str, int *tz_offset)
 {
        date_token *token, *tokens;
        time_t date;
-       
+
+       if (str == NULL)
+               return 0;
+
        if (!(tokens = datetok (str))) {
                if (tz_offset)
                        *tz_offset = 0;
                
-               return (time_t) 0;
+               return 0;
        }
        
        if (!(date = parse_rfc822_date (tokens, tz_offset)))