From: Junio C Hamano Date: Thu, 22 Mar 2018 21:24:16 +0000 (-0700) Subject: Merge branch 'jc/mailinfo-cleanup-fix' into maint X-Git-Tag: v2.16.3~18 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/bffce882fdf03aa7083d56d038c2dc2be58a9200?hp=b502aa4f45c9198ee498a09873f2c877911f23d7 Merge branch 'jc/mailinfo-cleanup-fix' into maint Corner case bugfix. * jc/mailinfo-cleanup-fix: mailinfo: avoid segfault when can't open files --- 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) {