<<< Date Index >>>     <<< Thread Index >>>

[PATCH] More valgrind memory leaks



The ones I got in my valgrind (all I did was launch mutt, log into my IMAP account, and exit):

   13 bytes in 1 blocks are definitely lost in loss record 24 of 279
      at 0x401B422: malloc (vg_replace_malloc.c:149)
      by 0x80C2020: safe_malloc (lib.c:146)
      by 0x80C21BB: safe_strdup (lib.c:217)
      by 0x80EA600: imap_parse_path (util.c:116)
      by 0x80E3CD0: imap_open_mailbox (imap.c:601)
      by 0x80928BC: mx_open_mailbox (mx.c:698)
      by 0x8087389: main (main.c:963)

This one is simple to fix - it's a throwaway variable. The attached patch (mutt.postleak.patch) should fix it.

784 (16 direct, 768 indirect) bytes in 1 blocks are definitely lost in loss record 217 of 279
      at 0x401B422: malloc (vg_replace_malloc.c:149)
      by 0x80C2020: safe_malloc (lib.c:146)
      by 0x80C6433: mutt_buffer_init (muttlib.c:1388)
      by 0x80EABF3: imap_new_idata (util.c:264)
      by 0x80E33C3: imap_conn_find (imap.c:350)
      by 0x80E3A54: imap_open_mailbox (imap.c:553)
      by 0x80928BC: mx_open_mailbox (mx.c:698)
      by 0x8087389: main (main.c:963)

The attached patch (mutt.imap_logout_leak.patch) seems to clear up the problem without making mutt die, but I'm somewhat suspicious of my fix... that many -> in a row makes me nervous.

However, once I added that patch, I started getting this in my valgrind report:

768 bytes in 1 blocks are definitely lost in loss record 226 of 277
      at 0x401C98D: realloc (vg_replace_malloc.c:306)
      by 0x80C20BC: safe_realloc (lib.c:171)
      by 0x80C65CB: mutt_buffer_printf (muttlib.c:1444)
      by 0x80E0CBB: imap_cmd_queue (command.c:84)
      by 0x80E60F5: imap_buffy_check (imap.c:1472)
      by 0x8055101: mutt_buffy_check (buffy.c:289)
      by 0x8066506: mutt_index_menu (curs_main.c:574)
      by 0x80873A2: main (main.c:966)

Which I haven't looked into yet... it seems the buffer gets reallocated after logout, maybe?

~Kyle
--
Morality, like art, means drawing a line someplace.
                                                       -- Oscar Wilde
--- imap.c.old  2006-07-08 04:05:14.000000000 -0400
+++ imap.c      2006-07-08 04:05:39.000000000 -0400
@@ -601,6 +601,7 @@ int imap_open_mailbox (CONTEXT* ctx)
   if (mx_is_imap (Postponed) && !imap_parse_path (Postponed, &pmx)
       && mutt_account_match (&pmx.account, &mx.account))
     imap_status (Postponed, 1);
+  FREE (&(pmx.mbox));
 
   snprintf (bufout, sizeof (bufout), "%s %s",
     ctx->readonly ? "EXAMINE" : "SELECT", buf);
--- imap.c.old  2006-07-08 04:18:24.000000000 -0400
+++ imap.c      2006-07-08 04:19:00.000000000 -0400
@@ -804,6 +804,7 @@ void imap_logout (IMAP_DATA* idata)
   while (imap_cmd_step (idata) == IMAP_CMD_CONTINUE)
     ;
 
+  FREE (&(((IMAP_DATA*)(idata->conn->data))->cmdbuf));
   FREE(& idata->buf);
   mutt_bcache_close (&idata->bcache);
   FREE(& idata);

Attachment: pgpEdPHvT6vmq.pgp
Description: PGP signature