[FFmpeg-cvslog] avformat/utils: use av_packet_make_refcounted to ensure packets are ref counted

James Almer git at videolan.org
Mon Apr 2 06:50:10 EEST 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sat Mar 24 22:33:32 2018 -0300| [02ae52db87270715bb81ddb912a2e3968e973d1f] | committer: James Almer

avformat/utils: use av_packet_make_refcounted to ensure packets are ref counted

Simplifies code, while also fixing a potential leak of side data in pkt.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=02ae52db87270715bb81ddb912a2e3968e973d1f
---

 libavformat/utils.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index f13c8208b1..39a36a5ac4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -867,13 +867,9 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
             continue;
         }
 
-        if (!pkt->buf) {
-            AVPacket tmp = { 0 };
-            err = av_packet_ref(&tmp, pkt);
-            if (err < 0)
-                return err;
-            *pkt = tmp;
-        }
+        err = av_packet_make_refcounted(pkt);
+        if (err < 0)
+            return err;
 
         if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&
             (pkt->flags & AV_PKT_FLAG_CORRUPT)) {



More information about the ffmpeg-cvslog mailing list