1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

xvid: Check memory allocation

This commit is contained in:
Vittorio Giovara 2015-05-31 14:54:48 +02:00 committed by Luca Barbato
parent 9fb483fede
commit fef2f4722b

View File

@ -276,6 +276,8 @@ static int xvid_strip_vol_header(AVCodecContext *avctx, AVPacket *pkt,
/* We need to store the header, so extract it */ /* We need to store the header, so extract it */
if (!avctx->extradata) { if (!avctx->extradata) {
avctx->extradata = av_malloc(vo_len); avctx->extradata = av_malloc(vo_len);
if (!avctx->extradata)
return AVERROR(ENOMEM);
memcpy(avctx->extradata, pkt->data, vo_len); memcpy(avctx->extradata, pkt->data, vo_len);
avctx->extradata_size = vo_len; avctx->extradata_size = vo_len;
} }
@ -594,11 +596,15 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
if (avctx->intra_matrix) { if (avctx->intra_matrix) {
intra = avctx->intra_matrix; intra = avctx->intra_matrix;
x->intra_matrix = av_malloc(sizeof(unsigned char) * 64); x->intra_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->intra_matrix)
return AVERROR(ENOMEM);
} else } else
intra = NULL; intra = NULL;
if (avctx->inter_matrix) { if (avctx->inter_matrix) {
inter = avctx->inter_matrix; inter = avctx->inter_matrix;
x->inter_matrix = av_malloc(sizeof(unsigned char) * 64); x->inter_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->inter_matrix)
return AVERROR(ENOMEM);
} else } else
inter = NULL; inter = NULL;