diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-10 13:18:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-10 13:18:05 +0200 |
commit | 50b5477616c8f6001a575fb953db45dd9a14662c (patch) | |
tree | 4af87567da08f040334d6ac938528c14b116825c /ffmpeg_opt.c | |
parent | eadba3e94daac2f48fd9ce7c9fdf5a562d3274ed (diff) | |
parent | b94e4acb4874843e914fd3cb8e089aff0756bb4a (diff) | |
download | ffmpeg-50b5477616c8f6001a575fb953db45dd9a14662c.tar.gz |
Merge commit 'b94e4acb4874843e914fd3cb8e089aff0756bb4a'
* commit 'b94e4acb4874843e914fd3cb8e089aff0756bb4a':
cmdutils_read_file: increment *size after writing the trailing \0
af_resample: unref out_buf when avresample_convert returns 0
af_amix: prevent memory leak on error path
vc1dec: prevent memory leak in error path
vc1dec: prevent memory leak on av_realloc error
af_channelmap: free old extended_data on reallocation
avconv: simplify memory allocation in copy_chapters
matroskaenc: check cue point validity before reallocation
swfenc: error out for more than 1 audio or video stream
build: link test programs only against static libs
Conflicts:
ffmpeg_opt.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg_opt.c')
-rw-r--r-- | ffmpeg_opt.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 26dcdff856..4db881b721 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1296,8 +1296,14 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) { AVFormatContext *is = ifile->ctx; AVFormatContext *os = ofile->ctx; + AVChapter **tmp; int i; + tmp = av_realloc_f(os->chapters, is->nb_chapters + os->nb_chapters, sizeof(*os->chapters)); + if (!tmp) + return AVERROR(ENOMEM); + os->chapters = tmp; + for (i = 0; i < is->nb_chapters; i++) { AVChapter *in_ch = is->chapters[i], *out_ch; int64_t ts_off = av_rescale_q(ofile->start_time - ifile->ts_offset, @@ -1323,11 +1329,7 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) if (copy_metadata) av_dict_copy(&out_ch->metadata, in_ch->metadata, 0); - os->nb_chapters++; - os->chapters = av_realloc_f(os->chapters, os->nb_chapters, sizeof(AVChapter)); - if (!os->chapters) - return AVERROR(ENOMEM); - os->chapters[os->nb_chapters - 1] = out_ch; + os->chapters[os->nb_chapters++] = out_ch; } return 0; } |