[FFmpeg-devel] [PATCH 6/6] avformat/utils: use av_packet_make_ref to ensure packets are ref counted
James Almer
jamrial at gmail.com
Sun Mar 25 07:03:39 EEST 2018
Simplifies code, while also fixing a potential leak of side data in pkt.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/utils.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f13c8208b1..fbf681e490 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_ref(pkt);
+ if (err < 0)
+ return err;
if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&
(pkt->flags & AV_PKT_FLAG_CORRUPT)) {
--
2.16.2
More information about the ffmpeg-devel
mailing list