]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rpza.c
pngdec: fix and simplify apng reference handling
[ffmpeg] / libavcodec / rpza.c
index cffbfe441652c0a0fe517ddd39371146a2522cec..02bbfe753f8d67566ef0826c8538d16e900c5863 100644 (file)
@@ -105,7 +105,10 @@ static int rpza_decode_stream(RpzaContext *s)
     /* Number of 4x4 blocks in frame. */
     total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
 
-    if ((ret = ff_reget_buffer(s->avctx, s->frame)) < 0)
+    if (total_blocks / 32 > bytestream2_get_bytes_left(&s->gb))
+        return AVERROR_INVALIDDATA;
+
+    if ((ret = ff_reget_buffer(s->avctx, s->frame, 0)) < 0)
         return ret;
     pixels = (uint16_t *)s->frame->data[0];
     stride = s->frame->linesize[0] / 2;