瀏覽代碼

Fix buffer overrun in ConvertAudio with different src/dst channel count

- Source or destination format also has to not be F32 to trigger bug
hspir404 11 月之前
父節點
當前提交
72a3eae0da
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/audio/SDL_audiocvt.c

+ 1 - 1
src/audio/SDL_audiocvt.c

@@ -325,7 +325,7 @@ void ConvertAudio(int num_frames,
 
 
     // Gain adjustment
     // Gain adjustment
     if (gain != 1.0f) {
     if (gain != 1.0f) {
-        float *buf = (float *)(dstconvert ? scratch : dst);
+        float *buf = (float *)((channelconvert || dstconvert) ? scratch : dst);
         const int total_samples = num_frames * src_channels;
         const int total_samples = num_frames * src_channels;
         if (src == buf) {
         if (src == buf) {
             for (int i = 0; i < total_samples; i++) {
             for (int i = 0; i < total_samples; i++) {