X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fapedec.c;h=58072d49ba256731a04219b17ec230a9598b8cad;hb=adc09a353c5ff467fdc924373e2ee1faf703b3b3;hp=6ec502b796a3f93164a6afa7df892a8d519a7f92;hpb=792845e436ddc5f3ce11ba02535a3372919061f2;p=ffmpeg diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 6ec502b796a..58072d49ba2 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -603,10 +603,14 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb, rice->ksum += out[i]; } rice->k = av_log2(rice->ksum / 10) + 1; + if (rice->k >= 24) + return; for (; i < 64; i++) { out[i] = get_rice_ook(&ctx->gb, rice->k); rice->ksum += out[i]; rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1; + if (rice->k >= 24) + return; } ksummax = 1 << rice->k + 7; ksummin = rice->k ? (1 << rice->k + 6) : 0; @@ -1434,7 +1438,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, } if (s->fileversion < 3950) // previous versions overread two bytes buf_size += 2; - av_fast_malloc(&s->data, &s->data_size, buf_size); + av_fast_padded_malloc(&s->data, &s->data_size, buf_size); if (!s->data) return AVERROR(ENOMEM); s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);