- if (strstr (notmuch_message_get_header (message, "to"), addr) != 0 ||
- strstr (notmuch_message_get_header (message, "cc"), addr) != 0)
+ to = notmuch_message_get_header (message, "to");
+ cc = notmuch_message_get_header (message, "cc");
+
+ if ((to && strstr (to, addr) != 0) ||
+ (cc && strstr (cc, addr) != 0))