From deb122b07dd496694cc1cc6f7aad0a42c8017a9d Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 8 Aug 2004 16:20:37 +0000 Subject: [PATCH] Fix a memory leak. --- ChangeLog | 4 ++++ muttlib.c | 18 +++++++++++++++++- protos.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9be1bc594..b5f9b7e64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-08-08 16:20:37 Thomas Glanzmann (roessler) + + * muttlib.c, protos.h: Fix a memory leak. + 2004-08-08 16:19:15 Thomas Roessler (roessler) * pgp.c, smime.c: Fix the PGP and S/MIME menus. Complaints diff --git a/muttlib.c b/muttlib.c index 896e9982c..914d52d43 100644 --- a/muttlib.c +++ b/muttlib.c @@ -638,17 +638,24 @@ void mutt_free_envelope (ENVELOPE **p) { 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); @@ -1356,6 +1363,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. * Always one byte bigger than necessary for the null terminator, and * the buffer is always null-terminated */ diff --git a/protos.h b/protos.h index a481e4f4b..821f731db 100644 --- a/protos.h +++ b/protos.h @@ -38,6 +38,7 @@ void mutt_buffer_free(BUFFER **); 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); -- 2.40.0