]> git.sesse.net Git - ffmpeg/commitdiff
avformat/utils: ensure that all packets in AVPacketList are reference counted
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 26 Sep 2019 00:05:58 +0000 (02:05 +0200)
committerJames Almer <jamrial@gmail.com>
Thu, 26 Sep 2019 00:54:18 +0000 (21:54 -0300)
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@gmail.com>
libavformat/internal.h
libavformat/utils.c

index 163587f416316acae52d3b5b1972cb29093b1a1b..67c35cc3e126332af60dfd7ab11914ae470f0c80 100644 (file)
@@ -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
index 19fee40eecc4d7db5c417a75a518afc736d6376e..9f8a5bfb631ebce04d9faa09c7a5d8caf8d9b4cd 100644 (file)
@@ -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);
     }