From 419ade4b6193c6eb626cda01b21e7091f42b2cc2 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Fri, 7 Dec 2012 22:57:02 +0100
Subject: [PATCH] lavc: check dimensions for video encoders

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
 libavcodec/utils.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index d042afa3c9b..3d33f85d97e 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1000,6 +1000,13 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         } else if (avctx->channel_layout) {
             avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
         }
+        if(avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+            if (avctx->width <= 0 || avctx->height <= 0) {
+                av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
+                ret = AVERROR(EINVAL);
+                goto free_and_end;
+            }
+        }
     }
 
     avctx->pts_correction_num_faulty_pts =
-- 
GitLab