notmuch show: Avoid segmentation for message with no subject.
authorCarl Worth <cworth@cworth.org>
Thu, 12 Nov 2009 07:00:58 +0000 (23:00 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 12 Nov 2009 07:00:58 +0000 (23:00 -0800)
It's safer to return an empty string rather than NULL for missing
header values.

lib/message-file.c
lib/notmuch.h

index 75caba6d8b055e5c3b57b2d72d1926381ff11fc8..8a3f8ee0fd2b66e04e0dd3e68b4abea37ae591f7 100644 (file)
@@ -238,7 +238,7 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
        return decoded_value;
 
     if (message->parsing_finished)
        return decoded_value;
 
     if (message->parsing_finished)
-       return NULL;
+       return "";
 
 #define NEXT_HEADER_LINE(closure)                              \
     while (1) {                                                        \
 
 #define NEXT_HEADER_LINE(closure)                              \
     while (1) {                                                        \
@@ -348,5 +348,5 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
                        header_desired);
     }
 
                        header_desired);
     }
 
-    return NULL;
+    return "";
 }
 }
index c1c7980aa06fe898e4a9697f9c8542b59b0d715d..40a1dca7e1cab7467c90372f330848733fba1056 100644 (file)
@@ -618,8 +618,8 @@ notmuch_message_get_date  (notmuch_message_t *message);
  * modified or freed by the caller (nor should it be referenced after
  * the message is destroyed).
  *
  * modified or freed by the caller (nor should it be referenced after
  * the message is destroyed).
  *
- * Returns NULL if the message does not contain a header line matching
- * 'header' of if any error occurs.
+ * Returns an empty string ("") if the message does not contain a
+ * header line matching 'header'. Returns NULL if any error occurs.
  */
 const char *
 notmuch_message_get_header (notmuch_message_t *message, const char *header);
  */
 const char *
 notmuch_message_get_header (notmuch_message_t *message, const char *header);