[FFmpeg-cvslog] avformat/movenc: Free extradata after successfull allocation of new instead of before

Michael Niedermayer git at videolan.org
Fri Aug 19 17:15:38 EEST 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Fri Aug 19 15:58:53 2016 +0200| [ca906e81909d0eee25ce745e162aa0f6ea6eb8e8] | committer: Michael Niedermayer

avformat/movenc: Free extradata after successfull allocation of new instead of before

This avoids erroring out with extradata lost and extradata size mismatching

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/movenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 282a3a8..1f55333 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4923,11 +4923,11 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
                 int side_size = 0;
                 uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
                 if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) {
-                    av_free(par->extradata);
-                    par->extradata = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE);
-                    if (!par->extradata) {
+                    void *newextra = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE);
+                    if (!newextra)
                         return AVERROR(ENOMEM);
-                    }
+                    av_free(par->extradata);
+                    par->extradata = newextra;
                     memcpy(par->extradata, side, side_size);
                     par->extradata_size = side_size;
                     mov->need_rewrite_extradata = 1;



More information about the ffmpeg-cvslog mailing list