From: Helmut Grohne Subject: hcom: fix dictionary resource leaks startread and stopread should release p->dictionary in all failure modes. --- a/src/hcom.c +++ b/src/hcom.c @@ -152,13 +152,18 @@ p->dictionary[i].dict_rightson); if ((unsigned) p->dictionary[i].dict_leftson >= dictsize || (unsigned) p->dictionary[i].dict_rightson >= dictsize) { + 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; @@ -240,6 +245,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"); @@ -250,8 +257,6 @@ lsx_fail_errno(ft,SOX_EFMT,"checksum error in HCOM data"); return (SOX_EOF); } - free(p->dictionary); - p->dictionary = NULL; return (SOX_SUCCESS); }