summaryrefslogtreecommitdiff
authorMichael Niedermayer <michaelni@gmx.at>2012-10-10 11:18:05 (GMT)
committer Michael Niedermayer <michaelni@gmx.at>2012-10-10 11:18:05 (GMT)
commit50b5477616c8f6001a575fb953db45dd9a14662c (patch)
tree4af87567da08f040334d6ac938528c14b116825c
parenteadba3e94daac2f48fd9ce7c9fdf5a562d3274ed (diff)
parentb94e4acb4874843e914fd3cb8e089aff0756bb4a (diff)
downloadffmpeg-50b5477616c8f6001a575fb953db45dd9a14662c.zip
ffmpeg-50b5477616c8f6001a575fb953db45dd9a14662c.tar.gz
ffmpeg-50b5477616c8f6001a575fb953db45dd9a14662c.tar.bz2
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
-rw-r--r--cmdutils.c2
-rw-r--r--ffmpeg_opt.c12
-rw-r--r--libavcodec/vc1dec.c12
-rw-r--r--libavfilter/af_amix.c4
-rw-r--r--libavfilter/af_channelmap.c2
-rw-r--r--libavfilter/af_resample.c5
-rw-r--r--libavformat/matroskaenc.c6
-rw-r--r--libavformat/swfenc.c8
-rw-r--r--library.mak6
9 files changed, 36 insertions, 21 deletions
diff --git a/cmdutils.c b/cmdutils.c
index a820001..8ef477f 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -1320,7 +1320,7 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
ret = AVERROR_EOF;
} else {
ret = 0;
- (*bufptr)[*size++] = '\0';
+ (*bufptr)[(*size)++] = '\0';
}
fclose(f);
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 26dcdff..4db881b 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;
}
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index e7085f6..639d317 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5369,9 +5369,10 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
break;
case VC1_CODE_FIELD: {
int buf_size3;
- slices = av_realloc(slices, sizeof(*slices) * (n_slices+1));
- if (!slices)
+ tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
+ if (!tmp)
goto err;
+ slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
@@ -5393,9 +5394,10 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
break;
case VC1_CODE_SLICE: {
int buf_size3;
- slices = av_realloc(slices, sizeof(*slices) * (n_slices+1));
- if (!slices)
+ tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
+ if (!tmp)
goto err;
+ slices = tmp;
slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!slices[n_slices].buf)
goto err;
@@ -5466,7 +5468,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (!s->context_initialized) {
if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
- return -1;
+ goto err;
s->low_delay = !avctx->has_b_frames || v->res_sprite;
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 9d0f998..c804cec 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -280,8 +280,10 @@ static int output_frame(AVFilterLink *outlink, int nb_samples)
return AVERROR(ENOMEM);
in_buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples);
- if (!in_buf)
+ if (!in_buf) {
+ avfilter_unref_buffer(out_buf);
return AVERROR(ENOMEM);
+ }
for (i = 0; i < s->nb_inputs; i++) {
if (s->input_state[i] == INPUT_ON) {
diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 50289c3..211abd7 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -337,8 +337,8 @@ static int channelmap_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *bu
if (buf->extended_data == buf->data) {
buf->extended_data = new_extended_data;
} else {
- buf->extended_data = new_extended_data;
av_free(buf->extended_data);
+ buf->extended_data = new_extended_data;
}
} else if (buf->extended_data != buf->data) {
av_free(buf->extended_data);
diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c
index 58a9b2a..c43d260 100644
--- a/libavfilter/af_resample.c
+++ b/libavfilter/af_resample.c
@@ -194,9 +194,10 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
buf_out->linesize[0], nb_samples,
buf->extended_data, buf->linesize[0],
buf->audio->nb_samples);
- if (ret < 0) {
+ if (ret <= 0) {
avfilter_unref_buffer(buf_out);
- goto fail;
+ if (ret < 0)
+ goto fail;
}
av_assert0(!avresample_available(s->avr));
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 38518e3..375f728 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -368,13 +368,13 @@ static int mkv_add_cuepoint(mkv_cues *cues, int stream, int64_t ts, int64_t clus
{
mkv_cuepoint *entries = cues->entries;
+ if (ts < 0)
+ return 0;
+
entries = av_realloc(entries, (cues->num_entries + 1) * sizeof(mkv_cuepoint));
if (entries == NULL)
return AVERROR(ENOMEM);
- if (ts < 0)
- return 0;
-
entries[cues->num_entries ].pts = ts;
entries[cues->num_entries ].tracknum = stream + 1;
entries[cues->num_entries++].cluster_pos = cluster_pos - cues->segment_offset;
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 4a5be12..b55f1a9 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -187,6 +187,10 @@ static int swf_write_header(AVFormatContext *s)
for(i=0;i<s->nb_streams;i++) {
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (swf->audio_enc) {
+ av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 audio stream\n");
+ return AVERROR_INVALIDDATA;
+ }
if (enc->codec_id == AV_CODEC_ID_MP3) {
swf->audio_enc = enc;
swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE);
@@ -197,6 +201,10 @@ static int swf_write_header(AVFormatContext *s)
return -1;
}
} else {
+ if (swf->video_enc) {
+ av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 video stream\n");
+ return AVERROR_INVALIDDATA;
+ }
if (enc->codec_id == AV_CODEC_ID_VP6F ||
enc->codec_id == AV_CODEC_ID_FLV1 ||
enc->codec_id == AV_CODEC_ID_MJPEG) {
diff --git a/library.mak b/library.mak
index 821fe7e..cc77729 100644
--- a/library.mak
+++ b/library.mak
@@ -35,7 +35,7 @@ install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
define RULES
$(EXAMPLES) $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
- $$(LD) $(LDFLAGS) $$(LD_O) $$^ $(FULLNAME:%=$(LD_LIB)) $(FFEXTRALIBS) $$(ELIBS)
+ $$(LD) $(LDFLAGS) $$(LD_O) $$^ $(FFEXTRALIBS) $$(ELIBS)
$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
$(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
@@ -94,8 +94,8 @@ endef
$(eval $(RULES))
-$(EXAMPLES) $(TESTPROGS) $(TOOLS): $(THIS_LIB) $(DEP_LIBS)
-$(TESTPROGS): $(SUBDIR)$(LIBNAME)
+$(EXAMPLES) $(TOOLS): $(THIS_LIB) $(DEP_LIBS)
+$(TESTPROGS): $(SUBDIR)$(LIBNAME) $(DEP_LIBS)
examples: $(EXAMPLES)
testprogs: $(TESTPROGS)