From: Carl Worth Date: Thu, 12 Nov 2009 07:00:58 +0000 (-0800) Subject: notmuch show: Avoid segmentation for message with no subject. X-Git-Tag: 0.1~526 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=091d18c54c046a08bda9d88982601589a1deea37 notmuch show: Avoid segmentation for message with no subject. It's safer to return an empty string rather than NULL for missing header values. --- diff --git a/lib/message-file.c b/lib/message-file.c index 75caba6d..8a3f8ee0 100644 --- a/lib/message-file.c +++ b/lib/message-file.c @@ -238,7 +238,7 @@ notmuch_message_file_get_header (notmuch_message_file_t *message, return decoded_value; if (message->parsing_finished) - return NULL; + return ""; #define NEXT_HEADER_LINE(closure) \ while (1) { \ @@ -348,5 +348,5 @@ notmuch_message_file_get_header (notmuch_message_file_t *message, header_desired); } - return NULL; + return ""; } diff --git a/lib/notmuch.h b/lib/notmuch.h index c1c7980a..40a1dca7 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -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). * - * 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);