]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/iff.c
movtextdec: fix return value for too small packets.
[ffmpeg] / libavcodec / iff.c
index 6f11f585871d0fd04f535139b4713fba94187398..a3241f6ea26eb4aa6179573aaa0c0471a8320850 100644 (file)
@@ -145,7 +145,7 @@ static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
     int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
 
     if (avctx->bits_per_coded_sample > 8) {
-        av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n");
+        av_log(avctx, AV_LOG_ERROR, "bits_per_coded_sample > 8 not supported\n");
         return AVERROR_INVALIDDATA;
     }
 
@@ -238,6 +238,11 @@ static int extract_header(AVCodecContext *const avctx,
                 s->mask_buf = av_malloc((s->planesize * 32) + FF_INPUT_BUFFER_PADDING_SIZE);
                 if (!s->mask_buf)
                     return AVERROR(ENOMEM);
+                if (s->bpp > 16) {
+                    av_log(avctx, AV_LOG_ERROR, "bpp %d too large for palette\n", s->bpp);
+                    av_freep(&s->mask_buf);
+                    return AVERROR(ENOMEM);
+                }
                 s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + FF_INPUT_BUFFER_PADDING_SIZE);
                 if (!s->mask_palbuf) {
                     av_freep(&s->mask_buf);