From 61813de118c901ee879e44225c49f4bf6828fe80 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Mon, 29 Apr 2019 14:57:29 +0100 Subject: [PATCH] libemail: fix attach code for degenerate cases --- email/attach.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/email/attach.c b/email/attach.c index 20af00785..f1861bbc4 100644 --- a/email/attach.c +++ b/email/attach.c @@ -39,6 +39,9 @@ */ void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach) { + if (!actx) + return; + if (actx->idxlen == actx->idxmax) { actx->idxmax += 5; @@ -58,6 +61,9 @@ void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach) */ void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new) { + if (!actx) + return; + if (actx->fp_len == actx->fp_max) { actx->fp_max += 5; @@ -76,6 +82,9 @@ void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new) */ void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body) { + if (!actx) + return; + if (actx->body_len == actx->body_max) { actx->body_max += 5; @@ -93,6 +102,9 @@ void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body) */ void mutt_actx_free_entries(struct AttachCtx *actx) { + if (!actx) + return; + for (int i = 0; i < actx->idxlen; i++) { if (actx->idx[i]->content) -- 2.40.0