avcodec/pngdec: fix mem leak in init()
authorBenoit Fouet <benoit.fouet@free.fr>
Wed, 3 Dec 2014 13:16:56 +0000 (14:16 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 3 Dec 2014 23:30:54 +0000 (00:30 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/pngdec.c

index b1e77e5..3905e0f 100644 (file)
@@ -1237,8 +1237,12 @@ static av_cold int png_dec_init(AVCodecContext *avctx)
     s->previous_picture.f = av_frame_alloc();
     s->last_picture.f = av_frame_alloc();
     s->picture.f = av_frame_alloc();
-    if (!s->previous_picture.f || !s->last_picture.f || !s->picture.f)
+    if (!s->previous_picture.f || !s->last_picture.f || !s->picture.f) {
+        av_frame_free(&s->previous_picture.f);
+        av_frame_free(&s->last_picture.f);
+        av_frame_free(&s->picture.f);
         return AVERROR(ENOMEM);
+    }
 
     if (!avctx->internal->is_copy) {
         avctx->internal->allocate_progress = 1;