Commit 21518f5a authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/libvpxenc: Check for av_malloc() failure

Fixes CID1271045
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 67d4d5f5
...@@ -717,9 +717,14 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt, ...@@ -717,9 +717,14 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
rawimg_alpha = &ctx->rawimg_alpha; rawimg_alpha = &ctx->rawimg_alpha;
rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3]; rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3];
u_plane = av_malloc(frame->linesize[1] * frame->height); 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); memset(u_plane, 0x80, frame->linesize[1] * frame->height);
rawimg_alpha->planes[VPX_PLANE_U] = u_plane; 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); memset(v_plane, 0x80, frame->linesize[2] * frame->height);
rawimg_alpha->planes[VPX_PLANE_V] = v_plane; rawimg_alpha->planes[VPX_PLANE_V] = v_plane;
rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0]; rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment