]> granicus.if.org Git - neomutt/commitdiff
null ptr deref - print_attachment_list
authorRichard Russon <rich@flatcap.org>
Mon, 19 Mar 2018 10:46:21 +0000 (10:46 +0000)
committerRichard Russon <rich@flatcap.org>
Tue, 20 Mar 2018 01:01:45 +0000 (01:01 +0000)
recvattach.c

index dbb89158b2c267f6afbfa0bb957aea0ff82e72ca..05f39ded9c6b9b4fc87c1be4ad628a0b8f40f6f3 100644 (file)
@@ -659,7 +659,8 @@ static void query_pipe_attachment(char *command, FILE *fp, struct Body *body, bo
 
 static void pipe_attachment(FILE *fp, struct Body *b, struct State *state)
 {
-  FILE *ifp = NULL;
+  if (!state || !state->fpout)
+    return;
 
   if (fp)
   {
@@ -670,7 +671,7 @@ static void pipe_attachment(FILE *fp, struct Body *b, struct State *state)
   }
   else
   {
-    ifp = fopen(b->filename, "r");
+    FILE *ifp = fopen(b->filename, "r");
     if (!ifp)
     {
       mutt_perror("fopen");
@@ -802,6 +803,12 @@ static void print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag,
           mutt_mktemp(newfile, sizeof(newfile));
           if (mutt_decode_save_attachment(fp, top, newfile, MUTT_PRINTING, 0) == 0)
           {
+            if (!state->fpout)
+            {
+              mutt_error("BUG in print_attachment_list().  Please report this. ");
+              return;
+            }
+
             ifp = fopen(newfile, "r");
             if (ifp)
             {