From: Kevin McCarthy Date: Sun, 9 Dec 2018 20:32:24 +0000 (-0800) Subject: Fix mutt_parse_rfc822_line() if lastp parameter is NULL. X-Git-Tag: mutt-1-12-rel~188 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=caf97ae9a294e439093437518fb2bb42bacae07d;p=mutt Fix mutt_parse_rfc822_line() if lastp parameter is NULL. It checked at the beginning before dereferencing, but not at the end. Since lastp is only used for the user_hdrs case, move the local variable and assignment inside that block to make it clear. --- diff --git a/parse.c b/parse.c index c862328d..75254958 100644 --- a/parse.c +++ b/parse.c @@ -1015,10 +1015,6 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short short do_2047, LIST **lastp) { int matched = 0; - LIST *last = NULL; - - if (lastp) - last = *lastp; switch (ascii_tolower (line[0])) { @@ -1316,9 +1312,14 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short /* Keep track of the user-defined headers */ if (!matched && user_hdrs) { + LIST *last = NULL; + + if (lastp) + last = *lastp; + /* restore the original line */ line[strlen (line)] = ':'; - + if (weed && option (OPTWEED) && mutt_matches_ignore (line, Ignore) && !mutt_matches_ignore (line, UnIgnore)) goto done; @@ -1333,11 +1334,12 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short last->data = safe_strdup (line); if (do_2047) rfc2047_decode (&last->data); + + if (lastp) + *lastp = last; } done: - - *lastp = last; return matched; }