X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fdsicinvideo.c;h=73eea9aeb7ee86db6b266c6a1e7baf9cfedd3990;hb=e5af9203098a889f36b759652615046254d45102;hp=37175d67b2e9528646644653471458412fdaf4dc;hpb=06476249cd2332e30b66576633b2827adf3478dd;p=ffmpeg diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c index 37175d67b2e..73eea9aeb7e 100644 --- a/libavcodec/dsicinvideo.c +++ b/libavcodec/dsicinvideo.c @@ -58,7 +58,6 @@ static av_cold int allocate_buffers(CinVideoContext *cin) cin->bitmap_table[i] = av_mallocz(cin->bitmap_size); if (!cin->bitmap_table[i]) { av_log(cin->avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n"); - destroy_buffers(cin); return AVERROR(ENOMEM); } } @@ -266,8 +265,11 @@ static int cinvideo_decode_frame(AVCodecContext *avctx, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); break; case 37: - cin_decode_huffman(buf, bitmap_frame_size, + res = cin_decode_huffman(buf, bitmap_frame_size, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size); + + if (cin->bitmap_size - avctx->discard_damaged_percentage*cin->bitmap_size/100 > res) + return AVERROR_INVALIDDATA; break; case 38: res = cin_decode_lzss(buf, bitmap_frame_size, @@ -287,7 +289,7 @@ static int cinvideo_decode_frame(AVCodecContext *avctx, break; } - if ((res = ff_reget_buffer(avctx, cin->frame)) < 0) + if ((res = ff_reget_buffer(avctx, cin->frame, 0)) < 0) return res; memcpy(cin->frame->data[1], cin->palette, sizeof(cin->palette)); @@ -319,7 +321,7 @@ static av_cold int cinvideo_decode_end(AVCodecContext *avctx) return 0; } -AVCodec ff_dsicinvideo_decoder = { +const AVCodec ff_dsicinvideo_decoder = { .name = "dsicinvideo", .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN video"), .type = AVMEDIA_TYPE_VIDEO,