[FFmpeg-devel] [PATCH 1/2] icodec: fix leaking pkt on error

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Wed Nov 9 00:59:45 EET 2016


Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavformat/icodec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index aad1416..becbc0f 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -174,8 +174,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         bytestream_put_le16(&buf, 0);
         bytestream_put_le32(&buf, 0);
 
-        if ((ret = avio_read(pb, buf, image->size)) != image->size)
+        if ((ret = avio_read(pb, buf, image->size)) != image->size) {
+            av_packet_unref(pkt);
             return ret < 0 ? ret : AVERROR_INVALIDDATA;
+        }
 
         st->codecpar->bits_per_coded_sample = AV_RL16(buf + 14);
 
-- 
2.10.2


More information about the ffmpeg-devel mailing list