From 2c1fae9184f6fc55e5f55be331c67990d6a1bde1 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 1 Feb 2022 14:27:52 -0500 Subject: Ensure close_file() callback always free()s data --- src/riff.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/riff.c b/src/riff.c index f5c1c23..a920d10 100644 --- a/src/riff.c +++ b/src/riff.c @@ -284,21 +284,15 @@ error_malloc_riff: } static void close_file(xas_riff *riff, xas_audio_stream *stream) { - if (lseek(riff->fd, 0, SEEK_SET) < 0) { - goto error_io; + if (lseek(riff->fd, 0, SEEK_SET) == 0) { + (void)header_write(riff); } - if (header_write(riff) < 0) { - goto error_header_write; + if (riff->file) { + (void)close(riff->fd); } - (void)close(riff->fd); - free(riff); - -error_header_write: -error_io: - return; } static ssize_t audio_drain(xas_riff *riff, -- cgit v1.2.3