]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Handle empty date value
authorAustin Clements <amdragon@mit.edu>
Mon, 6 Oct 2014 23:17:09 +0000 (17:17 -0600)
committerDavid Bremner <david@tethera.net>
Sat, 11 Oct 2014 05:10:12 +0000 (07:10 +0200)
In the interest of robustness, avoid undefined behavior of
sortable_unserialise if the date value is missing.  This shouldn't
happen now, but ghost messages will have blank date values.

lib/message.cc

index bbfc2500bd92f12dfade22db471fb6b22bf9613b..38bc92914163bc92441ee05f8aede64a65d3efca 100644 (file)
@@ -896,6 +896,9 @@ notmuch_message_get_date (notmuch_message_t *message)
        return 0;
     }
 
+    if (value.empty ())
+       /* sortable_unserialise is undefined on empty string */
+       return 0;
     return Xapian::sortable_unserialise (value);
 }