[FFmpeg-devel] smc: check for frame dimensions

Submitted by Xiao Yang on June 11, 2018, 6:49 a.m.

Details

Message ID SIXPR01MB0560223EEA8E63D384091999AD780@SIXPR01MB0560.apcprd01.prod.exchangelabs.com
State New
Headers show

Commit Message

Xiao Yang June 11, 2018, 6:49 a.m.
---
 libavcodec/smc.c |    7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/smc.c b/libavcodec/smc.c
index 3cb4834..fc1d308 100644
--- a/libavcodec/smc.c
+++ b/libavcodec/smc.c
@@ -421,6 +421,13 @@  static av_cold int smc_decode_init(AVCodecContext *avctx)
     s->avctx = avctx;
     avctx->pix_fmt = AV_PIX_FMT_PAL8;
 
+    if (!avctx->width || !avctx->height ||
+        (avctx->width & 1) || (avctx->height & 1)) {
+        av_log(avctx, AV_LOG_ERROR, "Invalid video dimensions: %dx%d\n",
+               avctx->width, avctx->height);
+        return AVERROR(EINVAL);
+    }
+
     s->frame = av_frame_alloc();
     if (!s->frame)
         return AVERROR(ENOMEM);