aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r--libavcodec/mjpegdec.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 1ffb074e59..4e103dd161 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1066,7 +1066,10 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
dc = mjpeg_decode_dc(s, s->dc_index[i]);
if(dc == 0xFFFFF)
return -1;
- if(bits<=8){
+ if ( h * mb_x + x >= s->width
+ || v * mb_y + y >= s->height) {
+ // Nothing to do
+ } else if (bits<=8) {
ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
if(y==0 && toprow){
if(x==0 && leftcol){
@@ -1134,7 +1137,10 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
dc = mjpeg_decode_dc(s, s->dc_index[i]);
if(dc == 0xFFFFF)
return -1;
- if(bits<=8){
+ if ( h * mb_x + x >= s->width
+ || v * mb_y + y >= s->height) {
+ // Nothing to do
+ } else if (bits<=8) {
ptr = s->picture_ptr->data[c] +
(linesize * (v * mb_y + y)) +
(h * mb_x + x); //FIXME optimize this crap