diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-08-19 15:58:53 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-08-19 16:02:16 +0200 |
commit | ca906e81909d0eee25ce745e162aa0f6ea6eb8e8 (patch) | |
tree | ef3418d33198b13aa556fe7bea2e6752ea35cc02 | |
parent | 4f6f56114e5618b601bd01a34d95cf750c7baa9b (diff) | |
download | ffmpeg-ca906e81909d0eee25ce745e162aa0f6ea6eb8e8.tar.gz |
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@niedermayer.cc>
-rw-r--r-- | libavformat/movenc.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 282a3a8fa2..1f55333c32 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; |