From 9f1f5c80eb4cf7b86523a5797974451ce45e042a Mon Sep 17 00:00:00 2001 From: Julian <31388661+jgraj@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:10:11 +0200 Subject: [PATCH] Add an assert for `stb_vorbis_decode_memory` call Return value of `stb_vorbis_decode_memory` is less than 0 for errors and we later malloc with that value, so 0 is still probably not good to have --- Sources/kinc/audio1/sound.c.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/kinc/audio1/sound.c.h b/Sources/kinc/audio1/sound.c.h index 6b19a10f3..1a005baa1 100644 --- a/Sources/kinc/audio1/sound.c.h +++ b/Sources/kinc/audio1/sound.c.h @@ -127,6 +127,7 @@ kinc_a1_sound_t *kinc_a1_sound_create(const char *filename) { int channels, sample_rate; int samples = stb_vorbis_decode_memory(filedata, (int)kinc_file_reader_size(&file), &channels, &sample_rate, (short **)&data); + kinc_affirm(samples > 0); sound->channel_count = (uint8_t)channels; sound->samples_per_second = (uint32_t)sample_rate; sound->size = samples * 2 * sound->channel_count;