]> git.notmuchmail.org Git - notmuch/commitdiff
add_message: Fix segfault for message with no Date header.
authorCarl Worth <cworth@cworth.org>
Fri, 6 Nov 2009 17:31:03 +0000 (09:31 -0800)
committerCarl Worth <cworth@cworth.org>
Fri, 6 Nov 2009 17:31:03 +0000 (09:31 -0800)
I'd fixed this earlier when I had a private copy of GMime's
date-parsing code, but I lost the fix when I recently switched to
calling the GMime function.

message.cc

index a7a0cb52eeec99f34d867d264bb5d42619ddfe31..28f19a88502dc79ff29210297abfbed4f5ef2562 100644 (file)
@@ -409,7 +409,12 @@ _notmuch_message_set_date (notmuch_message_t *message,
 {
     time_t time_value;
 
-    time_value = g_mime_utils_header_decode_date (date, NULL);
+    /* GMime really doesn't want to see a NULL date, so protect its
+     * sensibilities. */
+    if (date == NULL)
+       time_value = 0;
+    else
+       time_value = g_mime_utils_header_decode_date (date, NULL);
 
     message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP,
                            Xapian::sortable_serialise (time_value));