diff mbox

[FFmpeg-devel] avcodec/decode: don't increase hw frame size

Message ID 20171112130151.7841-1-timo@rothenpieler.org
State New
Headers show

Commit Message

Timo Rothenpieler Nov. 12, 2017, 1:01 p.m. UTC
In case the hw frames context does not return way too large frames,
but slightly smaller ones(for example height being 1080, while
coded_height is 1088), this causes failures because various code will
try to read/write beyond the frame size.
---
 libavcodec/decode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a7f1e23fc2..0a5ec6a21b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1491,8 +1491,8 @@  int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags
 
     if (avctx->hw_frames_ctx) {
         ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0);
-        frame->width  = avctx->coded_width;
-        frame->height = avctx->coded_height;
+        frame->width  = FFMIN(avctx->coded_width, frame->width);
+        frame->height = FFMIN(avctx->coded_height, frame->height);
         return ret;
     }