summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXANTRONIX Development2022-02-01 14:27:52 -0500
committerXANTRONIX Development2022-02-01 14:27:52 -0500
commit2c1fae9184f6fc55e5f55be331c67990d6a1bde1 (patch)
tree0610e0360a0ea940e906d4f82558ce64c8fbd197
parentf20a98aa7a2f418167d884df4da243986ba601ec (diff)
downloadxas-2c1fae9184f6fc55e5f55be331c67990d6a1bde1.tar.gz
xas-2c1fae9184f6fc55e5f55be331c67990d6a1bde1.tar.bz2
xas-2c1fae9184f6fc55e5f55be331c67990d6a1bde1.zip
Ensure close_file() callback always free()s data
-rw-r--r--src/riff.c14
1 files changed, 4 insertions, 10 deletions
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,