summaryrefslogtreecommitdiff
path: root/pith
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2018-05-13 01:38:56 -0600
committerEduardo Chappa <chappa@washington.edu>2018-05-13 01:38:56 -0600
commitaac7b10863bcfabe936feb5151e7e11123e13306 (patch)
tree8033a31daed6c94fcbdd41eef1682ba0539cfabd /pith
parent400647dcc1b040f82d22d539fc013f5e23132049 (diff)
downloadalpine-aac7b10863bcfabe936feb5151e7e11123e13306.tar.xz
* More changes to make Valgrind happy. Work in progress.
Diffstat (limited to 'pith')
-rw-r--r--pith/filter.c15
-rw-r--r--pith/filter.h2
-rw-r--r--pith/ical.c83
-rw-r--r--pith/ical.h1
-rw-r--r--pith/mailview.c17
-rw-r--r--pith/send.c6
-rw-r--r--pith/state.c8
-rw-r--r--pith/state.h2
-rw-r--r--pith/string.c6
9 files changed, 103 insertions, 37 deletions
diff --git a/pith/filter.c b/pith/filter.c
index 503c6cf4..ea98a4ea 100644
--- a/pith/filter.c
+++ b/pith/filter.c
@@ -5346,6 +5346,10 @@ html_a_output_info(HANDLER_S *hd)
if(risky && ((HTML_OPT_S *) hd->html_data->opt)->warnrisk_f)
(*((HTML_OPT_S *) hd->html_data->opt)->warnrisk_f)();
+ if(hd->dp)
+ so_give((STORE_S **) &hd->dp);
+
+
fs_give((void **) &url);
}
@@ -11406,3 +11410,14 @@ gf_local_nvtnl(FILTER_S *f, int flg)
}
}
+
+void
+free_filter_module_globals(void)
+{
+ FILTER_S *flt, *fltn = gf_master;
+
+ while((flt = fltn) != NULL){ /* free list of old filters */
+ fltn = flt->next;
+ fs_give((void **)&flt);
+ }
+}
diff --git a/pith/filter.h b/pith/filter.h
index ce146842..89e085fe 100644
--- a/pith/filter.h
+++ b/pith/filter.h
@@ -217,6 +217,6 @@ void *gf_prepend_editorial_opt(prepedtest_t, char *);
void gf_nvtnl_local(FILTER_S *, int);
void gf_local_nvtnl(FILTER_S *, int);
void *gf_url_hilite_opt(URL_HILITE_S *, HANDLE_S **, int);
-
+void free_filter_module_globals(void);
#endif /* PITH_FILTER_INCLUDED */
diff --git a/pith/ical.c b/pith/ical.c
index b0b1a6b6..dee78f58 100644
--- a/pith/ical.c
+++ b/pith/ical.c
@@ -76,7 +76,7 @@ void ical_set_date(ICLINE_S *, VTIMEZONE_S *);
void ical_set_date_vevent(void *, void *);
/* free properties */
-void ical_free_prop(void **, ICAL_PROP_S *);
+void ical_free_prop(void ***, ICAL_PROP_S *, int);
void ical_free_cline(void **);
void ical_free_param(ICAL_PARAMETER_S **);
void ical_free_gencline(void **);
@@ -291,12 +291,11 @@ ical_remove_escapes(char **textp)
}
*t = '\0'; /* tie off filtered text */
t = text; /* reset t to the beginning */
- if(rv == -1)
- fs_give((void **) &t);
- else{
+ if(rv == 0){
strncpy(*textp, t, strlen(t)); /* overwrite given text with filtered text */
(*textp)[strlen(t)] = '\0';
}
+ fs_give((void **) &t);
return rv;
}
@@ -304,7 +303,8 @@ void ical_debug(char *fcn, char *text)
{
char piece[50];
strncpy(piece, text, 49);
- dprint((9, "%s: %s", fcn, piece));
+ piece[sizeof(piece)-1] = '\0';
+ dprint((2, "%s: %s\n", fcn, piece));
}
/***
@@ -346,6 +346,7 @@ ical_free_gencline(void **giclpv)
if((*giclp)->cline) ical_free_cline((void **) &(*giclp)->cline);
if((*giclp)->next) ical_free_gencline((void **) &(*giclp)->next);
+ fs_give((void **)giclp);
}
void
@@ -364,7 +365,7 @@ ical_free_vcalendar(void **vcalpv)
Cal_comp i;
for(i = 0; i < VUnknown; i++)
if((*vcalp)->comp[i]) (ical_comp[i].give)(&(*vcalp)->comp[i]);
- fs_give((*vcalp)->comp);
+ fs_give((void **) &(*vcalp)->comp);
}
if((*vcalp)->uk_comp) ical_free_unknown_comp(&(*vcalp)->uk_comp);
fs_give(vcalpv);
@@ -377,7 +378,7 @@ ical_free_vevent(void **veventpv)
if(veventp == NULL || *veventp == NULL) return;
- ical_free_prop((*veventp)->prop, event_prop);
+ ical_free_prop(&(*veventp)->prop, event_prop, EvUnknown);
if((*veventp)->uk_prop) ical_free_gencline((void **) &(*veventp)->uk_prop);
if((*veventp)->valarm) ical_free_valarm((void **) &(*veventp)->valarm);
fs_give(veventpv);
@@ -396,7 +397,7 @@ ical_free_rrule(void **rrulepv)
RRULE_S **rrulep = (RRULE_S **) rrulepv;
if(rrulep && *rrulep){
- ical_free_prop((*rrulep)->prop, rrule_prop);
+ ical_free_prop(&(*rrulep)->prop, rrule_prop, RRUnknown);
ical_free_param(&(*rrulep)->param);
fs_give(rrulepv);
}
@@ -432,18 +433,18 @@ ical_free_vfreebusy(void **vfbpv)
}
void
-ical_free_prop(void **propv, ICAL_PROP_S *aux_comp)
+ical_free_prop(void ***propv, ICAL_PROP_S *aux_comp, int max)
{
int i, j;
- if(propv == NULL) return;
+ if(propv == NULL || *propv == NULL) return;
- for(i = 0; aux_comp[i].prop != NULL; i++)
- if(propv[i]){
+ for(i = 0; i < max; i++)
+ if((*propv)[i]){
for(j = 0; aux_comp[j].prop != NULL && aux_comp[j].pos != i; j++);
- if(aux_comp[j].give) (aux_comp[j].give)(&propv[i]);
+ if(aux_comp[j].give) (aux_comp[j].give)(&(*propv)[i]);
}
- fs_give(propv);
+ fs_give((void **) propv);
}
@@ -455,8 +456,7 @@ ical_free_vtimezone(void **vtzpv)
if(vtzp == NULL || *vtzp == NULL) return;
- ical_free_prop((*vtzp)->prop, tz_comp);
-
+ ical_free_prop(&(*vtzp)->prop, tz_comp, TZCUnknown);
if((*vtzp)->uk_prop) ical_free_gencline((void **) &(*vtzp)->uk_prop);
if((*vtzp)->standardc) ical_free_timezone((void **) &(*vtzp)->standardc);
if((*vtzp)->daylightc) ical_free_timezone((void **) &(*vtzp)->daylightc);
@@ -470,7 +470,7 @@ ical_free_timezone(void **tzpv)
if(tzp == NULL || *tzp == NULL) return;
- ical_free_prop((*tzp)->prop, tz_prop);
+ ical_free_prop(&(*tzp)->prop, tz_prop, TZPUnknown);
if((*tzp)->uk_prop) ical_free_gencline((void **) &(*tzp)->uk_prop);
if((*tzp)->next) ical_free_timezone((void **) &(*tzp)->next);
fs_give(tzpv);
@@ -478,6 +478,15 @@ ical_free_timezone(void **tzpv)
void ical_free_valarm(void **valarmpv)
{
+ VALARM_S **valarmp = (VALARM_S **) valarmpv;
+ int i, j;
+
+ if(valarmp == NULL || *valarmp == NULL) return;
+
+ ical_free_prop(&(*valarmp)->prop, alarm_prop, AlUnknown);
+ if((*valarmp)->uk_prop) ical_free_gencline((void **) &(*valarmp)->uk_prop);
+ if((*valarmp)->next) ical_free_timezone((void **) &(*valarmp)->next);
+ fs_give(valarmpv);
}
void
@@ -742,6 +751,8 @@ ical_cline_from_token(void *iclp, char **text, char *token)
{
ICLINE_S *icl;
+ ical_debug("ical_cline_from_token", *text);
+
icl = ical_parse_line(text, token);
if(iclp != NULL)
@@ -817,8 +828,8 @@ ical_parse_vcalendar(char **text)
s += ical_comp[i].len + 2;
v = (ical_comp[i].parse)(&s);
if(vcal->comp == NULL){
- vcal->comp = fs_get(VUnknown*sizeof(void *));
- memset((void *) vcal->comp, 0, VUnknown*sizeof(void *));
+ vcal->comp = fs_get((VUnknown+1)*sizeof(void *));
+ memset((void *) vcal->comp, 0, (VUnknown+1)*sizeof(void *));
}
if(vcal->comp[ical_comp[i].pos] == NULL)
@@ -973,8 +984,8 @@ ical_parse_vevent(char **text)
if(event_prop[i].parse){
void *v;
if(vevent->prop == NULL){
- vevent->prop = fs_get(EvUnknown*sizeof(void *));
- memset((void *)vevent->prop, 0, EvUnknown*sizeof(void *));
+ vevent->prop = fs_get((EvUnknown+1)*sizeof(void *));
+ memset((void *)vevent->prop, 0, (EvUnknown+1)*sizeof(void *));
}
v = vevent->prop[event_prop[i].pos];
v = (event_prop[i].parse)(v , &s, event_prop[i].prop);
@@ -1228,8 +1239,8 @@ ical_parse_valarm(char **text)
ical_free_unknown_comp(&uk_comp);
} else if(!struncmp(s, "END", t-s-1)){
s += 4; /* 4 = strlen("END:") */
- if(!struncmp(s, "ALARM\r\n", 7)){
- *text = s + 7; /* 7 = strlen("ALARM\r\n") */
+ if(!struncmp(s, "VALARM\r\n", 8)){
+ *text = s + 8; /* 8 = strlen("VALARM\r\n") */
return (void *) valarm;
}
} else{ Alarm_prop i;
@@ -1239,8 +1250,8 @@ ical_parse_valarm(char **text)
if(alarm_prop[i].parse){
void *v;
if(valarm->prop == NULL){
- valarm->prop = fs_get(AlUnknown*sizeof(void *));
- memset((void *)valarm->prop, 0, AlUnknown*sizeof(void *));
+ valarm->prop = fs_get((AlUnknown+1)*sizeof(void *));
+ memset((void *)valarm->prop, 0, (AlUnknown+1)*sizeof(void *));
}
v = valarm->prop[alarm_prop[i].pos];
v = (alarm_prop[i].parse)(v, &s, alarm_prop[i].prop);
@@ -2086,6 +2097,11 @@ adjust_date_rrule(struct tm *dtstart, RRULE_S *rrule)
void
ical_initialize(void)
{
+ static int inited = 0;
+
+ if(inited != 0)
+ return;
+
ical_buf_len = 1024;
ical_buf = fs_get(ical_buf_len+1);
@@ -2093,6 +2109,8 @@ ical_initialize(void)
day_zero.tm_year = 1601 - 1900;
day_zero.tm_mday = 1;
day_zero.tm_wday = 4;
+
+ inited++;
}
/* At this time, we are going to print the date in 24 hour format
@@ -2243,6 +2261,8 @@ ical_vevent_summary(VCALENDAR_S *vcal)
tzid != NULL ? ")" : "");
rv->evstart[len-1] = '\0';
}
+ if(tzid)
+ fs_give((void **)&tzid);
} /* end of if dtstart */
if((icl = (ICLINE_S *) vevent->prop[EvDuration]) != NULL){
@@ -2329,6 +2349,8 @@ ical_vevent_summary(VCALENDAR_S *vcal)
tzid != NULL ? ")" : "");
rv->evend[len-1] = '\0';
}
+ if(tzid)
+ fs_give((void **)&tzid);
} /* end of if dtend */
if((icl = (ICLINE_S *) vevent->prop[EvDtstamp]) != NULL){
@@ -2524,12 +2546,19 @@ free_vevent_summary(VEVENT_SUMMARY_S **vesy)
if((*vesy)->attendee){
for(i = 0; (*vesy)->attendee[i] != NULL; i++)
fs_give((void **) &(*vesy)->attendee[i]);
- fs_give((void **) (*vesy)->attendee);
+ fs_give((void **) &(*vesy)->attendee);
}
if((*vesy)->description){
for(i = 0; (*vesy)->description[i] != NULL; i++)
fs_give((void **) &(*vesy)->description[i]);
- fs_give((void **) (*vesy)->description);
+ fs_give((void **) &(*vesy)->description);
}
fs_give((void **) vesy);
}
+
+void
+ical_free_all(void)
+{
+ if(ical_buf)
+ fs_give((void **)&ical_buf);
+}
diff --git a/pith/ical.h b/pith/ical.h
index 7ff5865a..d1fb0b57 100644
--- a/pith/ical.h
+++ b/pith/ical.h
@@ -14,5 +14,6 @@ VEVENT_SUMMARY_S *ical_vevent_summary(VCALENDAR_S *);
void free_vevent_summary(VEVENT_SUMMARY_S **);
VCALENDAR_S *ical_parse_text(char *); /* this is the entry point */
+void ical_free_all(void);
#endif /* ifndef PITH_ICAL_INCLUDED */
diff --git a/pith/mailview.c b/pith/mailview.c
index 3fe1dd81..39fcfff6 100644
--- a/pith/mailview.c
+++ b/pith/mailview.c
@@ -156,7 +156,7 @@ format_message(long int msgno, ENVELOPE *env, struct mail_bodystruct *body,
{
char *decode_err = NULL;
HEADER_S h;
- int width;
+ int width, rv;
clear_cur_embedded_color();
@@ -201,9 +201,14 @@ format_message(long int msgno, ENVELOPE *env, struct mail_bodystruct *body,
}
/* write delimiter and body */
- if(gf_puts(NEWLINE, pc)
- && (decode_err = format_body(msgno, body, handlesp, &h, flgs, width, pc)) == NULL)
- return(1);
+ if(gf_puts(NEWLINE, pc)){
+ if((decode_err = format_body(msgno, body, handlesp, &h, flgs, width, pc)) == NULL)
+ rv = 1;
+ else
+ rv = 0;
+ }
+ clear_cur_embedded_color();
+ return(rv);
write_error:
@@ -211,7 +216,7 @@ format_message(long int msgno, ENVELOPE *env, struct mail_bodystruct *body,
if(!(flgs & FM_DISPLAY))
q_status_message1(SM_ORDER, 3, 4, _("Error writing message: %s"),
decode_err ? decode_err : error_description(errno));
-
+ clear_cur_embedded_color();
return(0);
}
@@ -521,6 +526,7 @@ format_calendar(long int msgno, BODY *body, HANDLE_S **handlesp, int flgs, int w
gf_puts(NEWLINE, pc);
continue;
}
+ caltext[callen] = '\0';
break;
case ENCQUOTEDPRINTABLE:
@@ -530,6 +536,7 @@ format_calendar(long int msgno, BODY *body, HANDLE_S **handlesp, int flgs, int w
gf_puts(NEWLINE, pc);
continue;
}
+ caltext[callen] = '\0';
break;
default: caltext = cpystr(rawtext);
diff --git a/pith/send.c b/pith/send.c
index 0c6a4085..8be908c2 100644
--- a/pith/send.c
+++ b/pith/send.c
@@ -4279,6 +4279,7 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s)
int add_trailing_crlf;
LOC_2022_JP ljp;
gf_io_t gc;
+ void *table = NULL;
dprint((4, "-- pine_rfc822_output_body: %d\n",
body ? body->type : 0));
@@ -4363,7 +4364,7 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s)
gf_line_test_opt(translate_utf8_to_2022_jp,&ljp));
}
else{
- void *table = utf8_rmap(charset);
+ table = utf8_rmap(charset);
if(table){
gf_link_filter(gf_convert_utf8_charset,
@@ -4410,6 +4411,9 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s)
display_message('x');
}
+ if(table)
+ fs_give((void **)&table);
+
gf_clear_so_readc(bodyso);
if(encode_error || !l_flush_net(TRUE))
diff --git a/pith/state.c b/pith/state.c
index 91da5bf6..5d83aba6 100644
--- a/pith/state.c
+++ b/pith/state.c
@@ -33,6 +33,7 @@ static char rcsid[] = "$Id: state.c 1074 2008-06-04 00:08:43Z hubert@u.washingto
#include "../pith/remote.h"
#include "../pith/list.h"
#include "../pith/smime.h"
+#include "../pith/ical.h"
/*
@@ -352,3 +353,10 @@ free_pinerc_s(PINERC_S **prc)
fs_give((void **)prc);
}
}
+
+void
+free_pith_module_globals(void)
+{
+ free_filter_module_globals();
+ ical_free_all();
+}
diff --git a/pith/state.h b/pith/state.h
index f09a5b24..d0f76cbc 100644
--- a/pith/state.h
+++ b/pith/state.h
@@ -394,6 +394,6 @@ void free_vars(struct pine *);
void free_variable_values(struct variable *);
PINERC_S *new_pinerc_s(char *);
void free_pinerc_s(PINERC_S **);
-
+void free_pith_module_globals(void);
#endif /* PITH_STATE_INCLUDED */
diff --git a/pith/string.c b/pith/string.c
index 0c158fb8..11a57fc0 100644
--- a/pith/string.c
+++ b/pith/string.c
@@ -2917,8 +2917,8 @@ free_strlist(STRLIST_S **strp)
void
convert_decimal_to_roman (char *rn, size_t len, long n, char l)
{
- char symbols[7];
- int amo[7];
+ char symbols[8];
+ int amo[8];
int i, j, k;
rn[0] = '\0';
@@ -2932,6 +2932,7 @@ convert_decimal_to_roman (char *rn, size_t len, long n, char l)
symbols[4] = l + 'x' - 'i';
symbols[5] = l + 'v' - 'i';
symbols[6] = l;
+ symbols[7] = '\0';
amo[0] = n/1000; n -= amo[0]*1000;
amo[1] = n/500; n -= amo[1]*500;
@@ -2940,6 +2941,7 @@ convert_decimal_to_roman (char *rn, size_t len, long n, char l)
amo[4] = n/10; n -= amo[4]*10;
amo[5] = n/5; n -= amo[5]*5;
amo[6] = n;
+ amo[7] = 0; /* make valgrind happy */
for(i = 0, j = 0; i < len && j < strlen(symbols); j++){
if(amo[j] < 4){