1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

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>
This commit is contained in:
Michael Niedermayer 2012-10-10 13:18:05 +02:00
commit 50b5477616
9 changed files with 36 additions and 21 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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));

View File

@ -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;

View File

@ -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) {

View File

@ -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)