diff mbox series

[FFmpeg-devel,1/4] avformat/flvdec: Avoid duplicating extradata when adding side-data

Message ID 20200524002554.28064-1-andreas.rheinhardt@gmail.com
State Accepted
Commit ed9bbcff6fd5579d9633eccbc9a28cb2d3892f85
Headers show
Series [FFmpeg-devel,1/4] avformat/flvdec: Avoid duplicating extradata when adding side-data
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 24, 2020, 12:25 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/flvdec.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 7c3e5b06c6..957acedf39 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1283,12 +1283,11 @@  retry_duration:
     pkt->stream_index = st->index;
     pkt->pos          = pos;
     if (flv->new_extradata[stream_type]) {
-        uint8_t *side = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
-                                                flv->new_extradata_size[stream_type]);
-        if (side) {
-            memcpy(side, flv->new_extradata[stream_type],
-                   flv->new_extradata_size[stream_type]);
-            av_freep(&flv->new_extradata[stream_type]);
+        int ret = av_packet_add_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+                                          flv->new_extradata[stream_type],
+                                          flv->new_extradata_size[stream_type]);
+        if (ret >= 0) {
+            flv->new_extradata[stream_type]      = NULL;
             flv->new_extradata_size[stream_type] = 0;
         }
     }