diff --git a/libavcodec/utils.c b/libavcodec/utils.c index d042afa3c9b021f47d38a53c2153c9d60dde4e4b..3d33f85d97e11d186316a015a306df406c0fea82 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 =