OSDN Git Service

avformat/ape: free packet on avio_read() failure
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 23 Dec 2013 17:09:58 +0000 (18:09 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 25 Dec 2013 01:32:40 +0000 (02:32 +0100)
Fixes memleak
Fixes: msan_uninit-mem_7fcc198b365b_8417_sh3.ape
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/ape.c

index 4e6e6bd..b677ba9 100644 (file)
@@ -417,8 +417,10 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
     AV_WL32(pkt->data    , nblocks);
     AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
     ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
-    if (ret < 0)
+    if (ret < 0) {
+        av_free_packet(pkt);
         return ret;
+    }
 
     pkt->pts = ape->frames[ape->currentframe].pts;
     pkt->stream_index = 0;