Fixes out of array access
Fixes: ce19e41f0ef1e52a23edc488faecdb58/asan_heap-oob_2504e97_4202_ffa0df1baed14022b9bfd4f8ac23d0cb.smk
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4a9af07a49295e014b059c1ab624c40345af5892)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
... | ... |
@@ -670,6 +670,10 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, |
670 | 670 |
|
671 | 671 |
/* get output buffer */ |
672 | 672 |
frame->nb_samples = unp_size / (avctx->channels * (bits + 1)); |
673 |
+ if (unp_size % (avctx->channels * (bits + 1))) { |
|
674 |
+ av_log(avctx, AV_LOG_ERROR, "unp_size %d is odd\n", unp_size); |
|
675 |
+ return AVERROR(EINVAL); |
|
676 |
+ } |
|
673 | 677 |
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) |
674 | 678 |
return ret; |
675 | 679 |
samples = (int16_t *)frame->data[0]; |