From daf1d90e4e59b49ae4d1bb2c3ada512d81349218 Mon Sep 17 00:00:00 2001 From: Piotr Bandurski Date: Sat, 14 Sep 2013 04:38:15 +0200 Subject: [PATCH] avcodec/mationpixels: free memory after malloc failures --- libavcodec/motionpixels.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 1a62d47..8f1362f 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -68,8 +68,12 @@ static av_cold int mp_decode_init(AVCodecContext *avctx) mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1; mp->vpt = av_mallocz(avctx->height * sizeof(YuvPixel)); mp->hpt = av_mallocz(h4 * w4 / 16 * sizeof(YuvPixel)); - if (!mp->changes_map || !mp->vpt || !mp->hpt) + if (!mp->changes_map || !mp->vpt || !mp->hpt) { + av_freep(&mp->changes_map); + av_freep(&mp->vpt); + av_freep(&mp->hpt); return AVERROR(ENOMEM); + } avctx->pix_fmt = AV_PIX_FMT_RGB555; avcodec_get_frame_defaults(&mp->frame); return 0; -- 1.7.9