]> granicus.if.org Git - neomutt/commitdiff
fix leaks (Address Sanitizer)
authorRichard Russon <rich@flatcap.org>
Mon, 5 Nov 2018 20:47:00 +0000 (20:47 +0000)
committerRichard Russon <rich@flatcap.org>
Mon, 5 Nov 2018 22:54:44 +0000 (22:54 +0000)
email/body.c
email/envelope.c
hook.c
imap/message.c
imap/util.c
init.c
mutt/logging.c
mx.c
nntp/newsrc.c
test/config/account.c

index 5253246b1144374cbd1140a3eaf6e984fb3b9090..7628f73aa453ca9d8668774c6c8eb7851660d0e5 100644 (file)
@@ -76,6 +76,7 @@ void mutt_body_free(struct Body **p)
     FREE(&b->content);
     FREE(&b->xtype);
     FREE(&b->subtype);
+    FREE(&b->language);
     FREE(&b->description);
     FREE(&b->form_name);
 
index 3667abbec41ed597160d2b4163e3ee1c30af08f3..c13f7268c9aeb852a1ef219380e9f924dd379694 100644 (file)
@@ -62,6 +62,7 @@ void mutt_env_free(struct Envelope **p)
   mutt_addr_free(&(*p)->sender);
   mutt_addr_free(&(*p)->reply_to);
   mutt_addr_free(&(*p)->mail_followup_to);
+  mutt_addr_free(&(*p)->x_original_to);
 
   FREE(&(*p)->list_post);
   FREE(&(*p)->subject);
diff --git a/hook.c b/hook.c
index 1582c5d0530ba45cef20fe93680443ead9178229..edb16f55f91d056b56d9fd0c035dd4ae0a198feb 100644 (file)
--- a/hook.c
+++ b/hook.c
@@ -290,6 +290,7 @@ static void delete_hook(struct Hook *h)
   if (h->regex.regex)
   {
     regfree(h->regex.regex);
+    FREE(&h->regex.regex);
   }
   mutt_pattern_free(&h->pattern);
   FREE(&h);
index 00fbb7054039a56416779556afd1ebff9f2ffd8b..671cf20eee787d2ac03151262fd97c93c2e7b0d3 100644 (file)
@@ -1099,6 +1099,7 @@ static int read_headers_fetch_new(struct ImapAccountData *adata, unsigned int ms
         m->hdrs[idx]->replied = h.data->replied;
         m->hdrs[idx]->received = h.received;
         m->hdrs[idx]->edata = (void *) (h.data);
+        m->hdrs[idx]->free_edata = imap_edata_free;
         STAILQ_INIT(&m->hdrs[idx]->tags);
         driver_tags_replace(&m->hdrs[idx]->tags, mutt_str_strdup(h.data->flags_remote));
 
index a7824feadddcb3e981d4af3927794b82ccdbe03b..af5edff9d0b56db0766121a91a50a1b7b83c1e83 100644 (file)
@@ -84,6 +84,14 @@ void imap_adata_free(void **ptr)
   FREE(&adata->buf);
   mutt_bcache_close(&adata->bcache);
   FREE(&adata->cmds);
+
+  if (adata->conn)
+  {
+    if (adata->conn->conn_close)
+      adata->conn->conn_close(adata->conn);
+    FREE(&adata->conn);
+  }
+
   FREE(ptr);
 }
 
@@ -187,6 +195,7 @@ void imap_get_parent_path(const char *path, char *buf, size_t buflen)
   if (!adata)
   {
     mutt_str_strfcpy(buf, path, buflen);
+    FREE(&mx.mbox);
     return;
   }
 
diff --git a/init.c b/init.c
index 049bdbb3f4271cbe2114ae4dbe37b2f24d4c6f47..d33187e159bc04707fbc26eb2cb8d498760ad75f 100644 (file)
--- a/init.c
+++ b/init.c
@@ -443,7 +443,7 @@ static bool get_hostname(void)
 #endif
   }
   if (Hostname)
-    cs_str_initial_set(Config, "hostname", mutt_str_strdup(Hostname), NULL);
+    cs_str_initial_set(Config, "hostname", Hostname, NULL);
 
   return true;
 }
index 04ea7de652a006a3d31a8c1f936edf99fe2492e9..74760a2a38e6eb578ddd007be6fb938b71837a6b 100644 (file)
@@ -294,7 +294,10 @@ int log_queue_add(struct LogLine *ll)
 
   if ((LogQueueMax > 0) && (LogQueueCount >= LogQueueMax))
   {
+    ll = STAILQ_FIRST(&LogQueue);
     STAILQ_REMOVE_HEAD(&LogQueue, entries);
+    FREE(&ll->message);
+    FREE(&ll);
   }
   else
   {
diff --git a/mx.c b/mx.c
index 6b394fbabac75a1a6cccc2b396548eb882d38f33..201ea9a6a554fcd97c4cccf248fad8be23af8a79 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1209,14 +1209,15 @@ void mx_alloc_memory(struct Mailbox *m)
     mutt_exit(1);
   }
 
+  m->hdrmax += 25;
   if (m->hdrs)
   {
-    mutt_mem_realloc(&m->hdrs, sizeof(struct Email *) * (m->hdrmax += 25));
+    mutt_mem_realloc(&m->hdrs, sizeof(struct Email *) * m->hdrmax);
     mutt_mem_realloc(&m->v2r, sizeof(int) * m->hdrmax);
   }
   else
   {
-    m->hdrs = mutt_mem_calloc((m->hdrmax += 25), sizeof(struct Email *));
+    m->hdrs = mutt_mem_calloc(m->hdrmax, sizeof(struct Email *));
     m->v2r = mutt_mem_calloc(m->hdrmax, sizeof(int));
   }
   for (int i = m->msg_count; i < m->hdrmax; i++)
index b6a5d2f1792b7f36b6bedacd9ae1f7a2f3d91ed8..5978ec39f3fdc283e91884c6ed748e41469b2717 100644 (file)
@@ -536,6 +536,7 @@ static void cache_expand(char *dst, size_t dstlen, struct ConnAccount *acct, con
     mutt_account_tourl(acct, &url);
     url.path = mutt_str_strdup(src);
     url_tostring(&url, file, sizeof(file), U_PATH);
+    FREE(&url.path);
   }
   else
     mutt_str_strfcpy(file, src ? src : "", sizeof(file));
index 70241370fc332279cb998094b5f40b21efcbad0a..987751a0c237687d0485dd0d71d4c051a87b0c2f 100644 (file)
@@ -194,19 +194,23 @@ void config_account(void)
   rc = cs_str_initial_set(cs, name, "42", &err);
   if (TEST_CHECK(CSR_RESULT(rc) != CSR_SUCCESS))
   {
-    TEST_MSG("%s\n", err.data);
+    TEST_MSG("Expected error\n");
+  }
+  else
+  {
+    TEST_MSG("This test should have failed\n");
     return;
   }
 
   mutt_buffer_reset(&err);
   rc = cs_str_initial_get(cs, name, &err);
-  if (TEST_CHECK(CSR_RESULT(rc) != CSR_SUCCESS))
+  if (TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
   {
-    TEST_MSG("Expected error\n");
+    TEST_MSG("Initial %s\n", err.data);
   }
   else
   {
-    TEST_MSG("This test should have failed\n");
+    TEST_MSG("%s\n", err.data);
     return;
   }