diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 61062b2a84a0cea03a5823550f7eaf15b95c9109..ee845de115e352da11428b73e709179b1102c666 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -639,6 +639,11 @@ static int flac_decode_frame(AVCodecContext *avctx, init_get_bits(&s->gb, buf, buf_size*8); + /* check that there is at least the smallest decodable amount of data. + this amount corresponds to the smallest valid FLAC frame possible. */ + if (buf_size < 24) + goto end; + /* check for inline header */ if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) { if (metadata_parse(s)) {