[FFmpeg-cvslog] avcodec/mationpixels: free memory after malloc failures

Piotr Bandurski git at videolan.org
Sat Sep 14 17:57:00 CEST 2013


ffmpeg | branch: master | Piotr Bandurski <ami_stuff at o2.pl> | Sat Sep 14 04:38:15 2013 +0200| [bb5e7d3b5ad21cefee5a1d1e895f01f70ea9a5d0] | committer: Michael Niedermayer

avcodec/mationpixels: free memory after malloc failures

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bb5e7d3b5ad21cefee5a1d1e895f01f70ea9a5d0
---

 libavcodec/motionpixels.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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;



More information about the ffmpeg-cvslog mailing list