From: Austin Clements <amdragon@mit.edu>
Date: Mon, 6 Oct 2014 23:17:09 +0000 (-0600)
Subject: lib: Handle empty date value
X-Git-Tag: 0.19_rc1~51
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=7487e2e2214b27407e542df164a4d23520bbd8d8;p=notmuch

lib: Handle empty date value

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.
---

diff --git a/lib/message.cc b/lib/message.cc
index bbfc2500..38bc9291 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -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);
 }