History

ffprobe: fix memleaks on errors

Michael Niedermayer committed 11 years ago

Commit 47111d31 parent 840c3c01 file · +12 −7Browse files

Unified · Split

ffprobe.c+12−7
@@ -2398,6 +2398,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) · 2397 unmodified lines
23982398 print_error(filename, err);
23992399 return err;
24002400 }
2401+ *fmt_ctx_ptr = fmt_ctx;
24012402 if (scan_all_pmts_set)
24022403 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
24032404 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) · 5 unmodified lines
24092410 opts = setup_find_stream_info_opts(fmt_ctx, codec_opts);
24102411 orig_nb_streams = fmt_ctx->nb_streams;
24112412
2412− if ((err = avformat_find_stream_info(fmt_ctx, opts)) < 0) {
2413− print_error(filename, err);
2414− return err;
2415− }
2413+ err = avformat_find_stream_info(fmt_ctx, opts);
2414+
24162415 for (i = 0; i < orig_nb_streams; i++)
24172416 av_dict_free(&opts[i]);
24182417 av_freep(&opts);
24192418
2419+ if (err < 0) {
2420+ print_error(filename, err);
2421+ return err;
2422+ }
2423+
24202424 av_dump_format(fmt_ctx, 0, filename, 0);
24212425
24222426 /* bind a decoder to each input stream */
@@ -2466,7 +2470,7 @@ static void close_input_file(AVFormatContext **ctx_ptr) · 43 unmodified lines
24662470
24672471 static int probe_file(WriterContext *wctx, const char *filename)
24682472 {
2469− AVFormatContext *fmt_ctx;
2473+ AVFormatContext *fmt_ctx = NULL;
24702474 int ret, i;
24712475 int section_id;
24722476
@@ -2475,7 +2479,7 @@ static int probe_file(WriterContext *wctx, const char *filename) · 2 unmodified lines
24752479
24762480 ret = open_input_file(&fmt_ctx, filename);
24772481 if (ret < 0)
2478− return ret;
2482+ goto end;
24792483
24802484 #define CHECK_END if (ret < 0) goto end
24812485
@@ -2533,7 +2537,8 @@ static int probe_file(WriterContext *wctx, const char *filename) · 51 unmodified lines
25332537 }
25342538
25352539 end:
2536− close_input_file(&fmt_ctx);
2540+ if (fmt_ctx)
2541+ close_input_file(&fmt_ctx);
25372542 av_freep(&nb_streams_frames);
25382543 av_freep(&nb_streams_packets);
25392544 av_freep(&selected_streams);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t