summaryrefslogtreecommitdiff
path: root/libavcodec/brenderpix.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/brenderpix.c')
-rw-r--r--libavcodec/brenderpix.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/brenderpix.c b/libavcodec/brenderpix.c
index 0556858de1..46b7a59aa4 100644
--- a/libavcodec/brenderpix.c
+++ b/libavcodec/brenderpix.c
@@ -204,6 +204,10 @@ static int pix_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
avpriv_request_sample(avctx, "Format %d", hdr.format);
return AVERROR_PATCHWELCOME;
}
+ bytes_per_scanline = bytes_pp * hdr.width;
+
+ if (bytestream2_get_bytes_left(&gb) < hdr.height * bytes_per_scanline)
+ return AVERROR_INVALIDDATA;
if ((ret = ff_set_dimensions(avctx, hdr.width, hdr.height)) < 0)
return ret;
@@ -261,7 +265,6 @@ static int pix_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
bytestream2_skip(&gb, 8);
// read the image data to the buffer
- bytes_per_scanline = bytes_pp * hdr.width;
bytes_left = bytestream2_get_bytes_left(&gb);
if (chunk_type != IMAGE_DATA_CHUNK || data_len != bytes_left ||