X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fsunrast.c;h=7e9a9b0be51481f8aa3aceda7411815e9ace58b4;hb=1c7f252783aec37e4ff8049476386f63afe91756;hp=baf184968f54895cc2e15ab6dd8532363a23434a;hpb=0728d644973c314785c26b3d0559ba829ca31641;p=ffmpeg diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index baf184968f5..7e9a9b0be51 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -100,14 +100,18 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, if (ret < 0) return ret; + /* scanlines are aligned on 16 bit boundaries */ + len = (depth * w + 7) >> 3; + alen = len + (len & 1); + + if (buf_end - buf < maplength + (len * h) * 3 / 256) + return AVERROR_INVALIDDATA; + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; p->pict_type = AV_PICTURE_TYPE_I; - if (buf_end - buf < maplength) - return AVERROR_INVALIDDATA; - if (depth > 8 && maplength) { av_log(avctx, AV_LOG_WARNING, "useless colormap found or file is corrupted, trying to recover\n"); @@ -136,10 +140,6 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, stride = p->linesize[0]; } - /* scanlines are aligned on 16 bit boundaries */ - len = (depth * w + 7) >> 3; - alen = len + (len & 1); - if (type == RT_BYTE_ENCODED) { int value, run; uint8_t *end = ptr + h * stride; @@ -205,7 +205,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, return buf - bufstart; } -AVCodec ff_sunrast_decoder = { +const AVCodec ff_sunrast_decoder = { .name = "sunrast", .long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"), .type = AVMEDIA_TYPE_VIDEO,