Browse Source

audio: Make sure we don't write to a NULL pointer.

(This _probably_ never happens in the current codebase, but just in case.)
Ryan C. Gordon 1 year ago
parent
commit
3e9991b535
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/audio/SDL_audiocvt.c

+ 3 - 1
src/audio/SDL_audiocvt.c

@@ -1119,7 +1119,9 @@ int SDL_ClearAudioStream(SDL_AudioStream *stream)
 
     SDL_LockMutex(stream->lock);
     SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2);
-    SDL_memset(stream->history_buffer, SDL_GetSilenceValueForFormat(stream->src_spec.format), stream->history_buffer_frames * stream->src_spec.channels * sizeof (float));
+    if (stream->history_buffer != NULL) {
+        SDL_memset(stream->history_buffer, SDL_GetSilenceValueForFormat(stream->src_spec.format), stream->history_buffer_frames * stream->src_spec.channels * sizeof (float));
+    }
     stream->future_buffer_filled_frames = 0;
     stream->flushed = SDL_FALSE;
     SDL_UnlockMutex(stream->lock);