summaryrefslogtreecommitdiff
path: root/pith/filter.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2018-05-18 17:12:19 -0600
committerEduardo Chappa <chappa@washington.edu>2018-05-18 17:12:19 -0600
commit58396d907b993f849a7f32b9665b793c9a5c5d0e (patch)
treeff6c9b6b1e075c9f05938a4292a4a7a6a31aa2f5 /pith/filter.c
parentae4bbcf4e8bb991ad3106ff0d7799276912c5815 (diff)
downloadalpine-58396d907b993f849a7f32b9665b793c9a5c5d0e.tar.xz
* Release memory of a conversion table to UTF-8, if this was created by
us. * Some distributions of OpenSSL do not define ERR_free_strings and EVP_cleanup, so we only execute them when defined. Reported by Erich Eckner.
Diffstat (limited to 'pith/filter.c')
-rw-r--r--pith/filter.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pith/filter.c b/pith/filter.c
index ea98a4ea..e4dbda07 100644
--- a/pith/filter.c
+++ b/pith/filter.c
@@ -1799,6 +1799,7 @@ gf_convert_8bit_charset(FILTER_S *f, int flg)
typedef struct _utf8c_s {
void *conv_table;
int report_err;
+ int free_this;
} UTF8C_S;
@@ -1913,9 +1914,12 @@ gf_convert_utf8_charset(FILTER_S *f, int flg)
}
else if(flg == GF_EOD){
(void) GF_FLUSH(f->next);
- if(f->opt)
+ 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);
fs_give((void **) &f->opt);
-
+ }
(*f->next->f)(f->next, GF_EOD);
}
else if(flg == GF_RESET){
@@ -1929,13 +1933,14 @@ gf_convert_utf8_charset(FILTER_S *f, int flg)
void *
-gf_convert_utf8_charset_opt(void *table, int report_err)
+gf_convert_utf8_charset_opt(void *table, int report_err, int free_this)
{
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);
}