Skip to content

Commit

Permalink
[raudio] Fixed buffer overflow when loading WAV files (#4539)
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebHeydon authored Nov 28, 2024
1 parent cd16c9e commit 58fe34d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/raudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 58fe34d

Please sign in to comment.