Skip to content

Commit

Permalink
Add an assert for stb_vorbis_decode_memory call
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jgraj authored Aug 8, 2024
1 parent bb20a3a commit 9f1f5c8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Sources/kinc/audio1/sound.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9f1f5c8

Please sign in to comment.