summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2018-03-22 14:24:16 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-03-22 14:24:16 -0700
commitbffce882fdf03aa7083d56d038c2dc2be58a9200 (patch)
tree4dab4e4c868a5a37a0471b5db527a7f80eb04ea4
parentMerge branch 'rb/hashmap-h-compilation-fix' into maint (diff)
parentmailinfo: avoid segfault when can't open files (diff)
downloadtgif-bffce882fdf03aa7083d56d038c2dc2be58a9200.tar.xz
Merge branch 'jc/mailinfo-cleanup-fix' into maint
Corner case bugfix. * jc/mailinfo-cleanup-fix: mailinfo: avoid segfault when can't open files
-rw-r--r--mailinfo.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mailinfo.c b/mailinfo.c
index a89db22ab0..d04142ccc7 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1167,11 +1167,13 @@ void clear_mailinfo(struct mailinfo *mi)
strbuf_release(&mi->inbody_header_accum);
free(mi->message_id);
- for (i = 0; mi->p_hdr_data[i]; i++)
- strbuf_release(mi->p_hdr_data[i]);
+ if (mi->p_hdr_data)
+ for (i = 0; mi->p_hdr_data[i]; i++)
+ strbuf_release(mi->p_hdr_data[i]);
free(mi->p_hdr_data);
- for (i = 0; mi->s_hdr_data[i]; i++)
- strbuf_release(mi->s_hdr_data[i]);
+ if (mi->s_hdr_data)
+ for (i = 0; mi->s_hdr_data[i]; i++)
+ strbuf_release(mi->s_hdr_data[i]);
free(mi->s_hdr_data);
while (mi->content < mi->content_top) {