| 1 | diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
|
|---|
| 2 | index 78c8900..84ef434 100644
|
|---|
| 3 | --- a/libavcodec/gifdec.c
|
|---|
| 4 | +++ b/libavcodec/gifdec.c
|
|---|
| 5 | @@ -181,8 +181,13 @@ static int gif_read_image(GifState *s, AVFrame *frame)
|
|---|
| 6 | /* verify that all the image is inside the screen dimensions */
|
|---|
| 7 | if (left + width > s->screen_width ||
|
|---|
| 8 | top + height > s->screen_height) {
|
|---|
| 9 | + if (width <= s->screen_width && height <= s->screen_height) {
|
|---|
| 10 | + left = FFMIN(left, s->screen_width - width);
|
|---|
| 11 | + top = FFMIN(top, s->screen_height - height);
|
|---|
| 12 | + } else {
|
|---|
| 13 | av_log(s->avctx, AV_LOG_ERROR, "image is outside the screen dimensions.\n");
|
|---|
| 14 | return AVERROR_INVALIDDATA;
|
|---|
| 15 | + }
|
|---|
| 16 | }
|
|---|
| 17 | if (width <= 0 || height <= 0) {
|
|---|
| 18 | av_log(s->avctx, AV_LOG_ERROR, "Invalid image dimensions.\n");
|
|---|