summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2018-05-19 00:18:27 -0600
committerEduardo Chappa <chappa@washington.edu>2018-05-19 00:18:27 -0600
commit2c08a863b7242f6658151a2e2592a6293c4dcb65 (patch)
treec0c788c662945a82e701f22d8e9a8823711e5ebd
parent58396d907b993f849a7f32b9665b793c9a5c5d0e (diff)
downloadalpine-2c08a863b7242f6658151a2e2592a6293c4dcb65.tar.xz
* Clear history when closing alpine, for commands that keep it.
* Reversing the clearing of the rmap memory.
-rw-r--r--alpine/alpine.c1
-rw-r--r--alpine/mailcmd.c69
-rw-r--r--alpine/mailcmd.h1
-rw-r--r--pico/line.c3
-rw-r--r--pith/filter.c10
-rw-r--r--pith/filter.h2
-rw-r--r--pith/reply.c3
-rw-r--r--pith/send.c2
8 files changed, 76 insertions, 15 deletions
diff --git a/alpine/alpine.c b/alpine/alpine.c
index c5f64d74..0ebb9534 100644
--- a/alpine/alpine.c
+++ b/alpine/alpine.c
@@ -3551,6 +3551,7 @@ free_alpine_module_globals(void)
free_passfile_cache();
#endif
free_message_queue();
+ free_mailcmd_globals();
}
#ifdef WIN32
diff --git a/alpine/mailcmd.c b/alpine/mailcmd.c
index 16c6b72f..d75aed6b 100644
--- a/alpine/mailcmd.c
+++ b/alpine/mailcmd.c
@@ -322,7 +322,8 @@ alpine_get_password(char *prompt, char *pass, size_t len)
0, len, prompt, NULL, NO_HELP, &flags);
}
-int smime_import_certificate(char *filename, char *full_filename, char *what, size_t len)
+int
+smime_import_certificate(char *filename, char *full_filename, char *what, size_t len)
{
int r = 1;
static HISTORY_S *history = NULL;
@@ -331,6 +332,13 @@ int smime_import_certificate(char *filename, char *full_filename, char *what, si
{-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;
@@ -2721,6 +2729,14 @@ 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");
@@ -3542,10 +3558,16 @@ cmd_export(struct pine *state, MSGNO_S *msgmap, int qline, int aopt)
long i, count = 0L, start_of_append, rawno;
gf_io_t pc;
STORE_S *store;
- struct variable *vars = ps_global->vars;
+ struct variable *vars = state ? ps_global->vars : NULL;
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");
@@ -3999,13 +4021,20 @@ simple_export(struct pine *ps, void *srctext, SourceType srctype, char *prompt_m
int r = 1, rflags = GER_NONE;
char filename[MAXPATH+1], full_filename[MAXPATH+1];
STORE_S *store = NULL;
- struct variable *vars = ps->vars;
+ struct variable *vars = ps ? ps->vars : NULL;
static HISTORY_S *history = NULL;
static ESCKEY_S simple_export_opts[] = {
{ctrl('T'), 10, "^T", N_("To Files")},
{-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;
@@ -5554,6 +5583,12 @@ 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
@@ -6318,6 +6353,12 @@ 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");
@@ -8104,6 +8145,12 @@ 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;
@@ -9702,6 +9749,22 @@ print_index(struct pine *state, MSGNO_S *msgmap, int agg)
}
+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, 0, 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 d4da965f..4c733ed6 100644
--- a/alpine/mailcmd.h
+++ b/alpine/mailcmd.h
@@ -101,6 +101,7 @@ 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/pico/line.c b/pico/line.c
index 57c39b04..f523ae86 100644
--- a/pico/line.c
+++ b/pico/line.c
@@ -91,8 +91,7 @@ lalloc(int used)
lp->l_size = size;
lp->l_used = used;
lp->l_sig = 0; /* assume it is not a signature line */
- lp->l_text[0].c = '\0'; /* this is not necessary */
- lp->l_text[0].a = lp->l_text[0].d = 0; /* but it makes valgrind happy */
+ memset((void *)lp->l_text, 0, size*sizeof(CELL));
return (lp);
}
diff --git a/pith/filter.c b/pith/filter.c
index e4dbda07..9f0182ba 100644
--- a/pith/filter.c
+++ b/pith/filter.c
@@ -1799,7 +1799,6 @@ gf_convert_8bit_charset(FILTER_S *f, int flg)
typedef struct _utf8c_s {
void *conv_table;
int report_err;
- int free_this;
} UTF8C_S;
@@ -1914,12 +1913,8 @@ gf_convert_utf8_charset(FILTER_S *f, int flg)
}
else if(flg == GF_EOD){
(void) GF_FLUSH(f->next);
- if(f->opt){
- if(((UTF8C_S *) f->opt)->conv_table != NULL
- && ((UTF8C_S *) f->opt)->free_this != 0)
- fs_give((void **) &((UTF8C_S *) f->opt)->conv_table);
+ if(f->opt)
fs_give((void **) &f->opt);
- }
(*f->next->f)(f->next, GF_EOD);
}
else if(flg == GF_RESET){
@@ -1933,14 +1928,13 @@ gf_convert_utf8_charset(FILTER_S *f, int flg)
void *
-gf_convert_utf8_charset_opt(void *table, int report_err, int free_this)
+gf_convert_utf8_charset_opt(void *table, int report_err)
{
UTF8C_S *utf8c;
utf8c = (UTF8C_S *) fs_get(sizeof(UTF8C_S));
utf8c->conv_table = table;
utf8c->report_err = report_err;
- utf8c->free_this = free_this;
return((void *) utf8c);
}
diff --git a/pith/filter.h b/pith/filter.h
index fdcaad73..89e085fe 100644
--- a/pith/filter.h
+++ b/pith/filter.h
@@ -183,7 +183,7 @@ void gf_qp_8bit(FILTER_S *, int);
void gf_8bit_qp(FILTER_S *, int);
void gf_convert_8bit_charset(FILTER_S *, int);
void gf_convert_utf8_charset(FILTER_S *, int);
-void *gf_convert_utf8_charset_opt(void *, int, int);
+void *gf_convert_utf8_charset_opt(void *, int);
void gf_2022_jp_to_euc(FILTER_S *, int);
void gf_native8bitjapanese_to_2022_jp(FILTER_S *, int);
void gf_euc_to_2022_jp(FILTER_S *, int);
diff --git a/pith/reply.c b/pith/reply.c
index 7bda78cb..398ee63d 100644
--- a/pith/reply.c
+++ b/pith/reply.c
@@ -2702,6 +2702,9 @@ get_body_part_text(MAILSTREAM *stream, struct mail_bodystruct *body,
*ret_charset = "UTF-8";
}
+ if(charset)
+ fs_give((void **) &charset);
+
/*
* just use detach, but add an auxiliary filter to insert prefix,
* and, perhaps, digest richtext
diff --git a/pith/send.c b/pith/send.c
index ff48de2d..460f6a24 100644
--- a/pith/send.c
+++ b/pith/send.c
@@ -4369,7 +4369,7 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s)
if(table){
gf_link_filter(gf_convert_utf8_charset,
- gf_convert_utf8_charset_opt(table,0,1));
+ gf_convert_utf8_charset_opt(table,0));
}
else{
/* else, just send it? */