Selaa lähdekoodia

audio: Fix potential NULL dereference in AudioStream gain adjustment.

You can end up with a NULL scratch buffer, which is otherwise not needed on
this path, then ConvertAudio will end up needing that scratch space to move
to float32 to apply gain.

Fixes #12091.
(I assume.)
Ryan C. Gordon 2 kuukautta sitten
vanhempi
commit
ccd5fcef12
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      src/audio/SDL_audiocvt.c

+ 1 - 1
src/audio/SDL_audiocvt.c

@@ -1022,7 +1022,7 @@ static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int o
         Uint8* work_buffer = NULL;
 
         // Ensure we have enough scratch space for any conversions
-        if ((src_format != dst_format) || (src_channels != dst_channels)) {
+        if ((src_format != dst_format) || (src_channels != dst_channels) || (gain != 1.0f)) {
             work_buffer = EnsureAudioStreamWorkBufferSize(stream, output_frames * max_frame_size);
 
             if (!work_buffer) {