diff mbox series

[FFmpeg-devel,1/3] avcodec/wmaprodec: Do not initialize unused variable to out of array value

Message ID 20211004222350.29657-1-michael@niedermayer.cc
State Accepted
Commit 07e46690532a21faf29938e7a06f452a780f0361
Headers show
Series [FFmpeg-devel,1/3] avcodec/wmaprodec: Do not initialize unused variable to out of array value | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Michael Niedermayer Oct. 4, 2021, 10:23 p.m. UTC
Fixes: out of array read
Fixes: 39452/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA2_fuzzer-4678745030524928.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/wmaprodec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Paul B Mahol Oct. 5, 2021, 8:47 a.m. UTC | #1
LGTM
diff mbox series

Patch

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 7b489943f43..ba7bddc51ca 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -1932,11 +1932,12 @@  static int xma_decode_packet(AVCodecContext *avctx, void *data,
             for (i = 0; i < s->num_streams; i++) {
                 const int start_ch = s->start_channel[i];
                 void *left[1] = { frame->extended_data[start_ch + 0] };
-                void *right[1] = { frame->extended_data[start_ch + 1] };
 
                 av_audio_fifo_read(s->samples[0][i], left, nb_samples);
-                if (s->xma[i].nb_channels > 1)
+                if (s->xma[i].nb_channels > 1) {
+                    void *right[1] = { frame->extended_data[start_ch + 1] };
                     av_audio_fifo_read(s->samples[1][i], right, nb_samples);
+                }
             }
 
             *got_frame_ptr = nb_samples > 0;