From 58fe34d9cc2dd1929efb864e5222f25253c4ad89 Mon Sep 17 00:00:00 2001 From: Caleb Heydon Date: Thu, 28 Nov 2024 16:58:35 -0500 Subject: [PATCH] [raudio] Fixed buffer overflow when loading WAV files (#4539) --- src/raudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/raudio.c b/src/raudio.c index 33c0c4e0..7de360fc 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -801,10 +801,10 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int wave.sampleRate = wav.sampleRate; wave.sampleSize = 16; wave.channels = wav.channels; - wave.data = (short *)RL_MALLOC(wave.frameCount*wave.channels*sizeof(short)); + wave.data = (short *)RL_MALLOC((size_t)wave.frameCount*wave.channels*sizeof(short)); // NOTE: We are forcing conversion to 16bit sample size on reading - drwav_read_pcm_frames_s16(&wav, wav.totalPCMFrameCount, wave.data); + drwav_read_pcm_frames_s16(&wav, wave.frameCount, wave.data); } else TRACELOG(LOG_WARNING, "WAVE: Failed to load WAV data");