summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorVictor Gallet <[email protected]>2020-12-31 13:28:16 +0100
committerGitHub <[email protected]>2020-12-31 13:28:16 +0100
commit9fe153ae2908ab4b92013252f325f86793a771b1 (patch)
tree278ec46a02076b8265cfd3904a7e9ae59b6a5b6f /src
parent2f966531a7e5cd7a7952cd8a18a12874a57e8654 (diff)
downloadraylib-9fe153ae2908ab4b92013252f325f86793a771b1.tar.gz
raylib-9fe153ae2908ab4b92013252f325f86793a771b1.zip
Avoid dereferencing a null pointer in the 'LoadSounsFromWave' function if the audioBuffer is null (#1499)
Diffstat (limited to 'src')
-rw-r--r--src/raudio.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/raudio.c b/src/raudio.c
index 660d438d..62229a32 100644
--- a/src/raudio.c
+++ b/src/raudio.c
@@ -766,7 +766,11 @@ Sound LoadSoundFromWave(Wave wave)
if (frameCount == 0) TRACELOG(LOG_WARNING, "SOUND: Failed to get frame count for format conversion");
AudioBuffer *audioBuffer = LoadAudioBuffer(AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO_DEVICE_SAMPLE_RATE, frameCount, AUDIO_BUFFER_USAGE_STATIC);
- if (audioBuffer == NULL) TRACELOG(LOG_WARNING, "SOUND: Failed to create buffer");
+ if (audioBuffer == NULL)
+ {
+ TRACELOG(LOG_WARNING, "SOUND: Failed to create buffer");
+ return sound; // early return to avoid dereferencing the audioBuffer null pointer
+ }
frameCount = (ma_uint32)ma_convert_frames(audioBuffer->data, frameCount, AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO_DEVICE_SAMPLE_RATE, wave.data, frameCountIn, formatIn, wave.channels, wave.sampleRate);
if (frameCount == 0) TRACELOG(LOG_WARNING, "SOUND: Failed format conversion");