]> granicus.if.org Git - mutt/commitdiff
Add NULL checks to rfc1524_free_entry().
authorKevin McCarthy <kevin@8t8.us>
Sat, 22 Jun 2019 23:13:46 +0000 (16:13 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sat, 22 Jun 2019 23:13:46 +0000 (16:13 -0700)
The existing code was fine, but make it robust like other free
functions in mutt, so the behavior isn't surprising.

attach.c
rfc1524.c

index db0d806fe17d0929bee8a6395fd0a44a92f331db..de58b55381b67e33b1e2a90d0d2ffa14f3851d4a 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -601,8 +601,7 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
 
 return_error:
 
-  if (entry)
-    rfc1524_free_entry (&entry);
+  rfc1524_free_entry (&entry);
   if (fp && (mutt_b2s (tempfile))[0])
     mutt_unlink (mutt_b2s (tempfile));
   else if (unlink_tempfile)
index 8ed8c95c649df01d9559e8dee64c2144cfa95d16..50ff84697ebc77ea2f47fb6657e5a14106578a57 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -398,8 +398,12 @@ rfc1524_entry *rfc1524_new_entry(void)
 
 void rfc1524_free_entry(rfc1524_entry **entry)
 {
-  rfc1524_entry *p = *entry;
+  rfc1524_entry *p;
 
+  if (!entry || !*entry)
+    return;
+
+  p = *entry;
   FREE (&p->command);
   FREE (&p->testcommand);
   FREE (&p->composecommand);