]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/avpacket.c
avformat: remove avio_flush() calls from the end of write_packet functions
[ffmpeg] / libavcodec / avpacket.c
index 11ac4e80cd2d5cf4a99a379ad1a644cc9ebbd434..858f827a0aa2cc61276fd6e8c04e68987ed8ad9c 100644 (file)
@@ -54,7 +54,7 @@ AVPacket *av_packet_alloc(void)
     if (!pkt)
         return pkt;
 
-    av_packet_unref(pkt);
+    av_init_packet(pkt);
 
     return pkt;
 }
@@ -522,11 +522,12 @@ fail:
 
 int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
 {
-    const uint8_t *end = data + size;
+    const uint8_t *end;
     int ret = 0;
 
     if (!dict || !data || !size)
         return ret;
+    end = data + size;
     if (size && end[-1])
         return AVERROR_INVALIDDATA;
     while (data < end) {
@@ -616,6 +617,7 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
         ret = packet_alloc(&dst->buf, src->size);
         if (ret < 0)
             goto fail;
+        av_assert1(!src->size || src->data);
         if (src->size)
             memcpy(dst->buf->data, src->data, src->size);
 
@@ -668,6 +670,7 @@ int av_packet_make_refcounted(AVPacket *pkt)
     ret = packet_alloc(&pkt->buf, pkt->size);
     if (ret < 0)
         return ret;
+    av_assert1(!pkt->size || pkt->data);
     if (pkt->size)
         memcpy(pkt->buf->data, pkt->data, pkt->size);
 
@@ -687,6 +690,7 @@ int av_packet_make_writable(AVPacket *pkt)
     ret = packet_alloc(&buf, pkt->size);
     if (ret < 0)
         return ret;
+    av_assert1(!pkt->size || pkt->data);
     if (pkt->size)
         memcpy(buf->data, pkt->data, pkt->size);