]> granicus.if.org Git - neomutt/commitdiff
fix some resource leaks
authorRichard Russon <rich@flatcap.org>
Tue, 27 Jun 2017 13:39:58 +0000 (14:39 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 28 Jun 2017 14:12:15 +0000 (15:12 +0100)
- CID 169545
- CID 169546
- CID 171381
- CID 171382

headers.c
init.c
mutt_lua.c
ncrypt/pgp.c

index 00802de0f0c8c55c5bfdfde63ef24abd111f2110..15a5b04f06c3c369afe0454e99080abb416e7b0c 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -68,6 +68,7 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg,
   if ((ifp = fopen(body, "r")) == NULL)
   {
     mutt_perror(body);
+    safe_fclose(&ofp);
     return;
   }
 
diff --git a/init.c b/init.c
index 9cb1e3d983b51139df22b010eb316e29e5d09e34..920a43ef16d1c7e7d7e5487a713abeaa8031e65d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -257,9 +257,9 @@ const struct Option *mutt_option_get(const char *s)
     return &MuttVars[idx];
   else if (mutt_strncmp("my_", s, 3) == 0)
   {
-    struct Option *opt = safe_malloc(sizeof(struct Option));
     if (!myvar_get(s))
       return NULL;
+    struct Option *opt = safe_malloc(sizeof(struct Option));
     opt->data = (unsigned long) safe_strdup(myvar_get(s));
     if (*((char **) opt->data))
     {
index 643517c3114b363e92ddf7ccdebcd206aa02626b..76d6be80a742db908ca11193d6efae417375bc7a 100644 (file)
@@ -116,7 +116,6 @@ static int _lua_mutt_set(lua_State *l)
   struct Buffer err;
   const char *param = lua_tostring(l, -2);
   mutt_debug(2, " * _lua_mutt_set(%s)\n", param);
-  struct Option *value = safe_malloc(sizeof(struct Option));
   const struct Option *tmp = mutt_option_get(param);
   if (!tmp)
   {
@@ -124,6 +123,7 @@ static int _lua_mutt_set(lua_State *l)
     return -1;
   }
 
+  struct Option *value = safe_malloc(sizeof(struct Option));
   memcpy(value, tmp, sizeof(struct Option));
   if (value)
   {
index bdd364dd9af2269baa7a08ac605e3d6dccda2094..257cd4c6544a5be2ac781c37b5c5ba7aa53f513d 100644 (file)
@@ -878,6 +878,7 @@ static struct Body *pgp_decrypt_part(struct Body *a, struct State *s,
   {
     mutt_error(_("Decryption failed"));
     pgp_void_passphrase();
+    safe_fclose(&pgperr);
     return NULL;
   }