yuv4mpegdec: fix leaking pkt in yuv4_read_packet
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Mon, 5 Dec 2016 21:56:36 +0000 (22:56 +0100)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Wed, 7 Dec 2016 23:26:41 +0000 (00:26 +0100)
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavformat/yuv4mpegdec.c

index a91645f..462b823 100644 (file)
@@ -295,9 +295,10 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
     ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN);
     if (ret < 0)
         return ret;
-    else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)
+    else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) {
+        av_packet_unref(pkt);
         return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
-
+    }
     pkt->stream_index = 0;
     pkt->pts = (off - s->internal->data_offset) / s->packet_size;
     pkt->duration = 1;