summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2018-06-16 00:36:14 -0600
committerEduardo Chappa <chappa@washington.edu>2018-06-16 00:36:14 -0600
commit19dfafb6bc3ed0d37036f21813b753a4dca91e52 (patch)
tree72ee32d9026dae4d1afb6e349f00375f9f207afe
parent6fc06defd55e7d00f620d40e52da47bc4c1b3a96 (diff)
downloadalpine-19dfafb6bc3ed0d37036f21813b753a4dca91e52.tar.xz
* Fix freeing history memory, and other changes to make Valgrind happy.
-rw-r--r--alpine/alpine.c4
-rw-r--r--alpine/mailcmd.c63
-rw-r--r--alpine/mailcmd.h1
-rw-r--r--alpine/titlebar.c2
-rw-r--r--pith/hist.c8
-rw-r--r--pith/pine.hlp2
6 files changed, 12 insertions, 68 deletions
diff --git a/alpine/alpine.c b/alpine/alpine.c
index 825ef09f..c9c9b37b 100644
--- a/alpine/alpine.c
+++ b/alpine/alpine.c
@@ -1308,6 +1308,9 @@ main(int argc, char **argv)
q_status_message(SM_ORDER | SM_DING, 4, 5,
_("Use Compose command to continue interrupted message."));
+ if(args.action == aaFolder && args.data.folder)
+ fs_give((void **) &args.data.folder);
+
#if defined(USE_QUOTAS)
{
long q;
@@ -3551,7 +3554,6 @@ free_alpine_module_globals(void)
free_passfile_cache();
#endif
free_message_queue();
- free_mailcmd_globals();
free_titlebar_globals();
}
diff --git a/alpine/mailcmd.c b/alpine/mailcmd.c
index bc6cf947..cf61c003 100644
--- a/alpine/mailcmd.c
+++ b/alpine/mailcmd.c
@@ -382,13 +382,6 @@ smime_import_certificate(char *filename, char *full_filename, char *what, size_t
{-1, 0, NULL, NULL},
{-1, 0, NULL, NULL}};
- /* special call to free history */
- if(filename == NULL && full_filename == NULL && what == NULL && len == 0){
- if(history != NULL)
- free_hist(&history);
- return 0;
- }
-
if(F_ON(F_ENABLE_TAB_COMPLETE,ps_global)){
eopts[r].ch = ctrl('I');
eopts[r].rval = 11;
@@ -2779,14 +2772,6 @@ save_prompt(struct pine *state, CONTEXT_S **cntxt, char *nfldr, size_t len_nfldr
CONTEXT_S *tc;
ESCKEY_S ekey[10];
- if(state == NULL && cntxt == NULL && nfldr == NULL && len_nfldr == 0
- && nmsgs == NULL && env == NULL && rawmsgno == 0L && section == NULL
- && dela == NULL && prea == NULL){
- if(history != NULL)
- free_hist(&history);
- return 0;
- }
-
if(!cntxt)
alpine_panic("no context ptr in save_prompt");
@@ -3612,12 +3597,6 @@ cmd_export(struct pine *state, MSGNO_S *msgmap, int qline, int aopt)
ESCKEY_S export_opts[5];
static HISTORY_S *history = NULL;
- if(state == NULL && msgmap == NULL && qline == 0 && aopt == 0){
- if(history != NULL)
- free_hist(&history);
- return 0;
- }
-
if(ps_global->restricted){
q_status_message(SM_ORDER, 0, 3,
"Alpine demo can't export messages to files");
@@ -4078,13 +4057,6 @@ simple_export(struct pine *ps, void *srctext, SourceType srctype, char *prompt_m
{-1, 0, NULL, NULL},
{-1, 0, NULL, NULL}};
- if(ps == NULL && srctext == NULL && srctype == CharStar
- && prompt_msg == NULL && lister_msg == NULL){
- if(history != NULL)
- free_hist(&history);
- return 0;
- }
-
if(F_ON(F_ENABLE_TAB_COMPLETE,ps)){
simple_export_opts[r].ch = ctrl('I');
simple_export_opts[r].rval = 11;
@@ -5633,12 +5605,6 @@ broach_folder(int qline, int allow_list, int *notrealinbox, CONTEXT_S **context)
ESCKEY_S ekey[9];
int rc, r, ku = -1, n, flags, last_rc = 0, inbox, done = 0;
- if(qline == 0 && allow_list == 0 && notrealinbox == NULL && context == NULL){
- if(history != NULL)
- free_hist(&history);
- return NULL;
- }
-
/*
* the idea is to provide a clue for the context the file name
* will be saved in (if a non-imap names is typed), and to
@@ -6403,12 +6369,6 @@ cmd_pipe(struct pine *state, MSGNO_S *msgmap, int aopt)
char pipe_command[MAXPATH];
ESCKEY_S pipe_opt[8];
- if(state == NULL && msgmap == NULL && aopt == 0){
- if(history != NULL)
- free_hist(&history);
- return 0;
- }
-
if(ps_global->restricted){
q_status_message(SM_ORDER | SM_DING, 0, 4,
"Alpine demo can't pipe messages");
@@ -8295,12 +8255,6 @@ select_by_text(MAILSTREAM *stream, MSGNO_S *msgmap, long int msgno, SEARCHSET **
static char *match_me = N_("[Match_My_Addresses]");
static char *dont_match_me = N_("[Don't_Match_My_Addresses]");
- if(stream == NULL && msgmap == NULL && msgno == 0 && limitsrch == NULL){
- if(history != NULL)
- free_hist(&history);
- return 0;
- }
-
ps_global->mangled_footer = 1;
savedsstring[0] = '\0';
ekey[0].ch = ekey[1].ch = ekey[2].ch = ekey[3].ch = -1;
@@ -9899,23 +9853,6 @@ print_index(struct pine *state, MSGNO_S *msgmap, int agg)
return(1);
}
-
-void
-free_mailcmd_globals(void)
-{
- /* these calls are not possible during normal operations, so these
- * are hacks to free history memory
- */
- smime_import_certificate(NULL, NULL, NULL, 0);
- save_prompt(NULL, NULL, NULL, 0, NULL, NULL, 0L, NULL, NULL, NULL);
- cmd_export(NULL, NULL, 0, 0);
- simple_export(NULL, NULL, CharStar, NULL, NULL);
- broach_folder(0, 0, NULL, NULL);
- cmd_pipe(NULL, NULL, 0);
- select_by_text(NULL, NULL, 0, NULL);
-}
-
-
#ifdef _WINDOWS
/*
diff --git a/alpine/mailcmd.h b/alpine/mailcmd.h
index 4c733ed6..d4da965f 100644
--- a/alpine/mailcmd.h
+++ b/alpine/mailcmd.h
@@ -101,7 +101,6 @@ int file_lister(char *, char *, size_t, char *, size_t, int, int);
int read_msg_prompt(long, char *);
void advance_cur_after_delete(struct pine *, MAILSTREAM *, MSGNO_S *, CmdWhere);
void free_list_sel(LIST_SEL_S **);
-void free_mailcmd_globals(void);
#ifdef _WINDOWS
int header_mode_callback(int, long);
int zoom_mode_callback(int, long);
diff --git a/alpine/titlebar.c b/alpine/titlebar.c
index 9f7d3564..4b51cc6a 100644
--- a/alpine/titlebar.c
+++ b/alpine/titlebar.c
@@ -1267,4 +1267,6 @@ free_titlebar_globals(void)
{
if(as_fname) fs_give((void **) &as_fname);
if(as_cname) fs_give((void **) &as_cname);
+ if(as.folder_name) fs_give((void **)&as.folder_name);
+ if(as.context_name) fs_give((void **)&as.context_name);
}
diff --git a/pith/hist.c b/pith/hist.c
index bef5598b..8f21b831 100644
--- a/pith/hist.c
+++ b/pith/hist.c
@@ -50,8 +50,12 @@ free_hist(HISTORY_S **history)
if(history && *history){
for(i = 0; i < (*history)->histsize; i++)
- if((*history)->hist[i] && (*history)->hist[i]->str)
- fs_give((void **) &(*history)->hist[i]->str);
+ if((*history)->hist[i]){
+ if((*history)->hist[i]->str)
+ fs_give((void **) &(*history)->hist[i]->str);
+ (*history)->hist[i]->cntxt = NULL; /* taken care of elsewhere */
+ fs_give((void **) &(*history)->hist[i]);
+ }
fs_give((void **) history);
}
diff --git a/pith/pine.hlp b/pith/pine.hlp
index cc394f1a..637f2e31 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 285 2018-06-14 16:50:05
+Alpine Commit 286 2018-06-16 00:36:08
============= h_news =================
<HTML>
<HEAD>