notmuch_message_get_header: Fix bogus return of NULL header.
[notmuch] / message.c
index 1a5994ff5a03f721b8ed0474a092328e73880db2..bd551ccd1a0a14eb899a0dc91ee019fbb18d26ae 100644 (file)
--- a/message.c
+++ b/message.c
@@ -273,8 +273,9 @@ notmuch_message_get_header (notmuch_message_t *message,
 
        match = (strcasecmp (header, header_desired) == 0);
 
 
        match = (strcasecmp (header, header_desired) == 0);
 
-       g_hash_table_insert (message->headers, header,
-                            xstrdup (message->value.str));
+       value = xstrdup (message->value.str);
+
+       g_hash_table_insert (message->headers, header, value);
 
        if (match)
            return value;
 
        if (match)
            return value;