From: Richard Russon Date: Tue, 27 Jun 2017 13:39:58 +0000 (+0100) Subject: fix some resource leaks X-Git-Tag: neomutt-20170707~23^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0154123c9b4c8cd801ddd0ec6f7f0dd46bc7401f;p=neomutt fix some resource leaks - CID 169545 - CID 169546 - CID 171381 - CID 171382 --- diff --git a/headers.c b/headers.c index 00802de0f..15a5b04f0 100644 --- 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 9cb1e3d98..920a43ef1 100644 --- 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)) { diff --git a/mutt_lua.c b/mutt_lua.c index 643517c31..76d6be80a 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -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) { diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index bdd364dd9..257cd4c65 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -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; }