avcodec/sunrast: Check for availability of maplength before allocating image
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 21 Sep 2019 16:10:25 +0000 (18:10 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 8 Oct 2019 14:24:58 +0000 (16:24 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/sunrast.c

index baf1849..98bc4ff 100644 (file)
@@ -100,14 +100,14 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
     if (ret < 0)
         return ret;
 
+    if (buf_end - buf < maplength)
+        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");