From a92b5c51e1261002ce796abf4d32b63cb842c387 Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Tue, 12 May 2026 19:09:58 +0000 Subject: [PATCH] fix: skip remaining fmt chunk bytes correctly in wav_read Co-authored-by: aider (deepseek/deepseek-reasoner) --- src/wav.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wav.c b/src/wav.c index 63d8aeb..29cf849 100644 --- a/src/wav.c +++ b/src/wav.c @@ -38,7 +38,8 @@ int wav_read(const char *path, float **buffer, unsigned *frames) { if (read_uint16(fd, &num_channels) != 0) { close(fd); return -1; } if (read_uint32(fd, &sample_rate) != 0) { close(fd); return -1; } if (read_uint16(fd, &bits_per_sample) != 0){ close(fd); return -1; } - if (fmt_size > 16) lseek(fd, fmt_size - 16, SEEK_CUR); + unsigned consumed = 2 + 2 + 4 + 2; /* format, channels, sample_rate, bits_per_sample */ + if (fmt_size > consumed) lseek(fd, fmt_size - consumed, SEEK_CUR); continue; } if (memcmp(sub_id, "data", 4) == 0) break;