aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@iscas.ac.cn>2023-04-17 10:32:51 +0800
committerJames Almer <jamrial@gmail.com>2023-04-16 23:36:03 -0300
commitb9ba036680b4164f6e415a85877dfa659ae4dde1 (patch)
tree10cbcfbb844e5b51168952e0bab363f7d952eebe /libavcodec
parentf8d0b13de5fe1a3d158dcc6f419c45c368b1dd4f (diff)
downloadffmpeg-b9ba036680b4164f6e415a85877dfa659ae4dde1.tar.gz
avcodec/msvideo1enc: Add check for av_malloc
Add the check for the return value of the av_malloc in order to avoid NULL pointer deference. Fixes: e4be3485af ("MS Video 1 encoder") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/msvideo1enc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c
index 36cfd39a85..1fb8be8883 100644
--- a/libavcodec/msvideo1enc.c
+++ b/libavcodec/msvideo1enc.c
@@ -84,6 +84,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if(!c->prev)
c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3));
+ if (!c->prev)
+ return AVERROR(ENOMEM);
prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1);
src = (const uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1));
if(c->keyint >= avctx->keyint_min)