[FFmpeg-devel] [PATCH] avformat: Fix error when writing uncoded frames.

Matt Oliver protogonoi at gmail.com
Sun Jan 24 10:06:02 CET 2016


commit "lavf: add automatic bitstream filtering; bump version" broke the use
av_interleaved_write_uncoded_frame as any input uncoded frame has an
invalid packet size that will crash when av_packet_ref tries to allocate
'size'
new memory. Since the packet is a temporary created within mux itself it
can be used directly without needing a new ref.

Signed-off-by: Matt Oliver <protogonoi at gmail.com>
---
 libavformat/mux.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 2da8cf2..cf1fb5c 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -832,11 +832,15 @@ int ff_interleave_add_packet(AVFormatContext *s,
AVPacket *pkt,
     if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
         av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
         av_assert0(((AVFrame *)pkt->data)->buf);
-    }
-
-    if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) {
-        av_free(this_pktl);
-        return ret;
+        this_pktl->pkt = *pkt;
+        pkt->buf = NULL;
+        pkt->side_data = NULL;
+        pkt->side_data_elems = 0;
+    } else {
+        if ((ret = av_packet_ref(&this_pktl->pkt, pkt)) < 0) {
+            av_free(this_pktl);
+            return ret;
+        }
     }

     if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avformat-Fix-error-when-writing-uncoded-frames.patch
Type: application/octet-stream
Size: 1573 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160124/605ec317/attachment.obj>


More information about the ffmpeg-devel mailing list