From 133dafe24fc7167b049bb14fb5ec2d199d8cddcc Mon Sep 17 00:00:00 2001
From: Rostislav Pehlivanov <atomnuker@gmail.com>
Date: Wed, 26 Jul 2017 23:54:14 +0100
Subject: [PATCH] pngdec: fix potential memory leak

Fixes CID1412026.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
---
 libavcodec/pngdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index f83884dfc22..4fc1c5a0627 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -863,8 +863,11 @@ static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f)
 
     av_bprint_finalize(&bp, (char **)&data);
 
-    if (!(sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len)))
+    sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len);
+    if (!sd) {
+        av_free(data);
         return AVERROR(ENOMEM);
+    }
 
     av_dict_set(&sd->metadata, "name", profile_name, 0);
     memcpy(sd->data, data, bp.len);
-- 
GitLab