[FFmpeg-devel] [PATCH] lavf/img2dec: Fix memory leak

Przemysław Sobala przemyslaw.sobala at grupawp.pl
Tue Sep 29 12:14:41 CEST 2015


Fixes #4886
---
 libavformat/img2dec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 70f0b09..fcd2b76 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -444,8 +444,12 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
     }
 
     res = av_new_packet(pkt, size[0] + size[1] + size[2]);
-    if (res < 0)
+    if (res < 0) {
+        for (i = 0; i < 3; i++) {
+            avio_closep(&f[i]);
+        }
         return res;
+    }
     pkt->stream_index = 0;
     pkt->flags       |= AV_PKT_FLAG_KEY;
     if (s->ts_from_file) {
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list