From: Michael Niedermayer Date: Sun, 22 Feb 2015 01:40:16 +0000 (+0100) Subject: avcodec/libvpxenc: Check for av_malloc() failure X-Git-Tag: android-x86-6.0-r1~139 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=21518f5a0a6b644d1dedda5650c15bc3df62a567;p=android-x86%2Fexternal-ffmpeg.git avcodec/libvpxenc: Check for av_malloc() failure Fixes CID1271045 Signed-off-by: Michael Niedermayer --- diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 4cb0e21458..9ad0c548b9 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -717,9 +717,14 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt, rawimg_alpha = &ctx->rawimg_alpha; rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3]; u_plane = av_malloc(frame->linesize[1] * frame->height); + v_plane = av_malloc(frame->linesize[2] * frame->height); + if (!u_plane || !v_plane) { + av_free(u_plane); + av_free(v_plane); + return AVERROR(ENOMEM); + } memset(u_plane, 0x80, frame->linesize[1] * frame->height); rawimg_alpha->planes[VPX_PLANE_U] = u_plane; - v_plane = av_malloc(frame->linesize[2] * frame->height); memset(v_plane, 0x80, frame->linesize[2] * frame->height); rawimg_alpha->planes[VPX_PLANE_V] = v_plane; rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0];