ref: f07dfa6b839c70648a0c9eedd2429199d08e27a7
parent: 20de3746460ca48eebc4ea883d6b58f80827dfa4
author: Helmut Grohne <helmut@subdivi.de>
date: Wed Aug 16 22:03:02 EDT 2023
hcom: fix dictionary resource leaks startread and stopread should release p->dictionary in all failure modes.
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -166,13 +166,18 @@
p->dictionary[i].dict_rightson);
if (!dictvalid(i, dictsize, p->dictionary[i].dict_leftson,
p->dictionary[i].dict_rightson)) {
+ free(p->dictionary);
+ p->dictionary = NULL;
lsx_fail_errno(ft, SOX_EHDR, "Invalid dictionary");
return SOX_EOF;
}
}
rc = lsx_skipbytes(ft, (size_t) 1); /* skip pad byte */
- if (rc)
+ if (rc) {
+ free(p->dictionary);
+ p->dictionary = NULL;
return rc;
+ }
/* Initialized the decompression engine */
p->checksum = checksum;
@@ -254,6 +259,8 @@
{
register priv_t *p = (priv_t *) ft->priv;
+ free(p->dictionary);
+ p->dictionary = NULL;
if (p->huffcount != 0)
{
lsx_fail_errno(ft,SOX_EFMT,"not all HCOM data read");
@@ -264,8 +271,6 @@
lsx_fail_errno(ft,SOX_EFMT,"checksum error in HCOM data");
return (SOX_EOF);
}
- free(p->dictionary);
- p->dictionary = NULL;
return (SOX_SUCCESS);
}