Commit ca906e81 authored by Michael Niedermayer's avatar 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: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 4f6f5611
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment