* [PATCH] hcom: fix double free on writing zero-length file
@ 2015-08-29 11:38 Mans Rullgard
2015-09-07 1:05 ` Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Mans Rullgard @ 2015-08-29 11:38 UTC (permalink / raw)
To: sox-devel
---
src/hcom.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/hcom.c b/src/hcom.c
index e76820e..c62b020 100644
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -432,9 +432,10 @@ static int stopwrite(sox_format_t * ft)
int rc = SOX_SUCCESS;
/* Compress it all at once */
- if (compressed_len)
+ if (compressed_len) {
compress(ft, &compressed_data, (int32_t *)&compressed_len);
- free(p->data);
+ free(p->data);
+ }
/* Write the header */
lsx_writebuf(ft, "\000\001A", (size_t) 3); /* Dummy file name "A" */
--
2.5.0
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hcom: fix double free on writing zero-length file
2015-08-29 11:38 [PATCH] hcom: fix double free on writing zero-length file Mans Rullgard
@ 2015-09-07 1:05 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-09-07 1:05 UTC (permalink / raw)
To: sox-devel
Mans Rullgard <mans@mansr.com> wrote:
> +++ b/src/hcom.c
> @@ -432,9 +432,10 @@ static int stopwrite(sox_format_t * ft)
> int rc = SOX_SUCCESS;
>
> /* Compress it all at once */
> - if (compressed_len)
> + if (compressed_len) {
> compress(ft, &compressed_data, (int32_t *)&compressed_len);
> - free(p->data);
> + free(p->data);
> + }
Tested successfully with: sox $INPUT x.hcom trim 0
A side note: As somebody who has never heard of hcom until now, much
less read the code, it was not immediately obvious to me what the
problem was or whether it introduced a new leaks until I skimmed through
the entire stopwrite and compress functions :x
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-07 1:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-29 11:38 [PATCH] hcom: fix double free on writing zero-length file Mans Rullgard
2015-09-07 1:05 ` Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/sox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).