From: Richard Russon Date: Thu, 10 May 2018 11:57:48 +0000 (+0100) Subject: fix coverity defects X-Git-Tag: neomutt-20180512~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a959c61ea105f744bdd36b54accd6fd03fb313f;p=neomutt fix coverity defects --- diff --git a/handler.c b/handler.c index 077a96202..cef5784b1 100644 --- a/handler.c +++ b/handler.c @@ -1270,6 +1270,7 @@ static int multilingual_handler(struct Body *a, struct State *s) if (mustfree) mutt_body_free(&a); + FREE(&preferred_languages); return rc; } diff --git a/hcache/hcache.c b/hcache/hcache.c index 1fedd5ade..99d2a63ee 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -225,8 +225,7 @@ static unsigned char *dump_char_size(char *c, unsigned char *d, int *off, p = mutt_str_substr_dup(c, c + size); if (mutt_ch_convert_string(&p, Charset, "utf-8", 0) == 0) { - c = p; - size = mutt_str_strlen(c) + 1; + size = mutt_str_strlen(p) + 1; } } @@ -279,7 +278,8 @@ static void restore_char(char **c, const unsigned char *d, int *off, bool conver char *tmp = mutt_str_strdup(*c); if (mutt_ch_convert_string(&tmp, "utf-8", Charset, 0) == 0) { - mutt_str_replace(c, tmp); + FREE(c); + *c = tmp; } else { diff --git a/init.c b/init.c index 96ae1886c..a24298670 100644 --- a/init.c +++ b/init.c @@ -2827,7 +2827,7 @@ static int parse_set(struct Buffer *buf, struct Buffer *s, unsigned long data, #endif else { - snprintf(err->data, err->dsize, _("%s: unknown type"), MuttVars[idx].name); + snprintf(err->data, err->dsize, _("%s: unknown type"), (idx >= 0) ? MuttVars[idx].name : "unknown"); r = -1; break; } diff --git a/mutt/charset.c b/mutt/charset.c index ec85bf3db..32994775a 100644 --- a/mutt/charset.c +++ b/mutt/charset.c @@ -289,6 +289,7 @@ int mutt_ch_convert_nonmime_string(char **ps) s = mutt_str_substr_dup(u, u + ulen); int m = mutt_ch_convert_string(&s, fromcode, Charset, 0); FREE(&fromcode); + FREE(&s); if (m == 0) { return 0;