diff mbox

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

Message ID 5d4d54f0-b35a-ca27-6ce6-58f2f919c3f6@googlemail.com
State Accepted
Headers show

Commit Message

Andreas Cadhalpun Nov. 8, 2016, 10:59 p.m. UTC
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavformat/icodec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 9, 2016, 4:25 p.m. UTC | #1
On Tue, Nov 08, 2016 at 11:59:45PM +0100, Andreas Cadhalpun wrote:
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavformat/icodec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

should be ok

thx

[...]
Andreas Cadhalpun Nov. 9, 2016, 8:18 p.m. UTC | #2
On 09.11.2016 17:25, Michael Niedermayer wrote:
> On Tue, Nov 08, 2016 at 11:59:45PM +0100, Andreas Cadhalpun wrote:
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
>> ---
>>  libavformat/icodec.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> should be ok

Pushed (after rebasing).

Best regards,
Andreas
diff mbox

Patch

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);