[FFmpeg-cvslog] avformat/utils: ensure that all packets in AVPacketList are reference counted

Andreas Rheinhardt git at videolan.org
Thu Sep 26 03:56:02 EEST 2019


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Sep 26 02:05:58 2019 +0200| [b6be2be765b3f9104ca5bc9f608a934db0fc012a] | committer: James Almer

avformat/utils: ensure that all packets in AVPacketList are reference counted

This is done so that its data is really owned by the packet.
This was already true for the current callers.

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

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

 libavformat/internal.h | 3 ++-
 libavformat/utils.c    | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 163587f416..67c35cc3e1 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -763,7 +763,8 @@ void ff_format_set_url(AVFormatContext *s, char *url);
  *
  * @param head  List head element
  * @param tail  List tail element
- * @param pkt   The packet being appended
+ * @param pkt   The packet being appended. The data described in it will
+ *              be made reference counted if it isn't already.
  * @param flags Any combination of FF_PACKETLIST_FLAG_* flags
  * @return 0 on success, negative AVERROR value on failure. On failure,
            the list is unchanged
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 19fee40eec..9f8a5bfb63 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -460,6 +460,11 @@ int ff_packet_list_put(AVPacketList **packet_buffer,
             return ret;
         }
     } else {
+        ret = av_packet_make_refcounted(pkt);
+        if (ret < 0) {
+            av_free(pktl);
+            return ret;
+        }
         av_packet_move_ref(&pktl->pkt, pkt);
     }
 



More information about the ffmpeg-cvslog mailing list