Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-01-21 07:35:50 +0300
committerMichael Niedermayer <michaelni@gmx.at>2015-01-21 15:51:26 +0300
commit47111d366dff9beeee6f536e4d815dc4e862d10e (patch)
treede0ddf5bf832e97db396970efbda5690a4f9e06a /ffprobe.c
parent840c3c05316a59c70a7470ed27aaa9c2f3ba410a (diff)
ffprobe: fix memleaks on errors
Found-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffprobe.c')
-rw-r--r--ffprobe.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ffprobe.c b/ffprobe.c
index faddc16b62..38879f177b 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2398,6 +2398,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
print_error(filename, err);
return err;
}
+ *fmt_ctx_ptr = fmt_ctx;
if (scan_all_pmts_set)
av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
@@ -2409,14 +2410,17 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
opts = setup_find_stream_info_opts(fmt_ctx, codec_opts);
orig_nb_streams = fmt_ctx->nb_streams;
- if ((err = avformat_find_stream_info(fmt_ctx, opts)) < 0) {
- print_error(filename, err);
- return err;
- }
+ err = avformat_find_stream_info(fmt_ctx, opts);
+
for (i = 0; i < orig_nb_streams; i++)
av_dict_free(&opts[i]);
av_freep(&opts);
+ if (err < 0) {
+ print_error(filename, err);
+ return err;
+ }
+
av_dump_format(fmt_ctx, 0, filename, 0);
/* bind a decoder to each input stream */
@@ -2466,7 +2470,7 @@ static void close_input_file(AVFormatContext **ctx_ptr)
static int probe_file(WriterContext *wctx, const char *filename)
{
- AVFormatContext *fmt_ctx;
+ AVFormatContext *fmt_ctx = NULL;
int ret, i;
int section_id;
@@ -2475,7 +2479,7 @@ static int probe_file(WriterContext *wctx, const char *filename)
ret = open_input_file(&fmt_ctx, filename);
if (ret < 0)
- return ret;
+ goto end;
#define CHECK_END if (ret < 0) goto end
@@ -2533,7 +2537,8 @@ static int probe_file(WriterContext *wctx, const char *filename)
}
end:
- close_input_file(&fmt_ctx);
+ if (fmt_ctx)
+ close_input_file(&fmt_ctx);
av_freep(&nb_streams_frames);
av_freep(&nb_streams_packets);
av_freep(&selected_streams);