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

Re: [PATCH] fix memleaks in the envelope freeing function



Hello together,
here is the second version of the patch which additional includes a
prototype for the newley introduced mutt_free_buffer function.

        Thomas
diff -Nru a/muttlib.c b/muttlib.c
--- a/muttlib.c 2004-08-08 14:01:00 +02:00
+++ b/muttlib.c 2004-08-08 14:01:00 +02:00
@@ -638,17 +638,24 @@
 {
   if (!*p) return;
   rfc822_free_address (&(*p)->return_path);
+  rfc822_free_address (&(*p)->from);
   rfc822_free_address (&(*p)->to);
   rfc822_free_address (&(*p)->cc);
   rfc822_free_address (&(*p)->bcc);
   rfc822_free_address (&(*p)->sender);
-  rfc822_free_address (&(*p)->from);
   rfc822_free_address (&(*p)->reply_to);
   rfc822_free_address (&(*p)->mail_followup_to);
+
+  FREE (&(*p)->list_post);
   FREE (&(*p)->subject);
+  /* real_subj is just an offset to subject and shouldn't be freed */
   FREE (&(*p)->message_id);
   FREE (&(*p)->supersedes);
   FREE (&(*p)->date);
+  FREE (&(*p)->x_label);
+
+  mutt_free_buffer (&(*p)->spam);
+
   mutt_free_list (&(*p)->references);
   mutt_free_list (&(*p)->in_reply_to);
   mutt_free_list (&(*p)->userhdrs);
@@ -1354,6 +1361,15 @@
 void mutt_buffer_addch (BUFFER* buf, char c)
 {
   mutt_buffer_add (buf, &c, 1);
+}
+
+void mutt_free_buffer (BUFFER **p)
+{
+  if (!*p) return;
+
+   FREE(&(*p)->data);
+   /* dptr is just an offset to data and shouldn't be freed */
+   FREE(p);
 }
 
 /* dynamically grows a BUFFER to accomodate s, in increments of 128 bytes.
diff -Nru a/protos.h b/protos.h
--- a/protos.h  2004-08-08 14:01:00 +02:00
+++ b/protos.h  2004-08-08 14:01:00 +02:00
@@ -38,6 +38,7 @@
 void mutt_buffer_add (BUFFER*, const char*, size_t);
 void mutt_buffer_addstr (BUFFER*, const char*);
 void mutt_buffer_addch (BUFFER*, char);
+void mutt_free_buffer (BUFFER **);
 
 #define mutt_system(x) _mutt_system(x,0)
 int _mutt_system (const char *, int);

Attachment: pgpjcxklpmFCl.pgp
Description: PGP signature