[FFmpeg-cvslog] avformat/mux: keep AVPacket fields consistent in ff_write_chained()

Michael Niedermayer git at videolan.org
Thu Jul 24 23:40:57 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Jul 24 22:33:21 2014 +0200| [383a04a127734d25c1ef7839c489bba297855801] | committer: Michael Niedermayer

avformat/mux: keep AVPacket fields consistent in ff_write_chained()

This might have caused double frees in theory, i do not have a test case
though

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/mux.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 308b255..3abeccf 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -963,6 +963,7 @@ int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
                      AVFormatContext *src)
 {
     AVPacket local_pkt;
+    int ret;
 
     local_pkt = *pkt;
     local_pkt.stream_index = dst_stream;
@@ -978,7 +979,11 @@ int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
         local_pkt.duration = av_rescale_q(pkt->duration,
                                           src->streams[pkt->stream_index]->time_base,
                                           dst->streams[dst_stream]->time_base);
-    return av_write_frame(dst, &local_pkt);
+
+    ret = av_write_frame(dst, &local_pkt);
+    pkt->buf = local_pkt.buf;
+    pkt->destruct = local_pkt.destruct;
+    return ret;
 }
 
 static int av_write_uncoded_frame_internal(AVFormatContext *s, int stream_index,



More information about the ffmpeg-cvslog mailing list