wmavoice: fix stack overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
This commit is contained in:
Ronald S. Bultje 2012-03-21 15:47:11 -07:00
parent 3c9267673e
commit 262196445c

View File

@ -1440,8 +1440,7 @@ static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx,
int pitch[MAX_BLOCKS], last_block_pitch; int pitch[MAX_BLOCKS], last_block_pitch;
/* Parse frame type ("frame header"), see frame_descs */ /* Parse frame type ("frame header"), see frame_descs */
int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], block_nsamples;
block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks;
if (bd_idx < 0) { if (bd_idx < 0) {
av_log(ctx, AV_LOG_ERROR, av_log(ctx, AV_LOG_ERROR,
@ -1449,6 +1448,8 @@ static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx,
return -1; return -1;
} }
block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks;
/* Pitch calculation for ACB_TYPE_ASYMMETRIC ("pitch-per-frame") */ /* Pitch calculation for ACB_TYPE_ASYMMETRIC ("pitch-per-frame") */
if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) { if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) {
/* Pitch is provided per frame, which is interpreted as the pitch of /* Pitch is provided per frame, which is interpreted as the pitch of