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
2398 print_error(filename, err);2398 print_error(filename, err);
2399 return err;2399 return err;
2400 }2400 }
2401 *fmt_ctx_ptr = fmt_ctx;
2401 if (scan_all_pmts_set)2402 if (scan_all_pmts_set)
2402 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);2403 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
2403 if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {2404 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
2409 opts = setup_find_stream_info_opts(fmt_ctx, codec_opts);2410 opts = setup_find_stream_info_opts(fmt_ctx, codec_opts);
2410 orig_nb_streams = fmt_ctx->nb_streams;2411 orig_nb_streams = fmt_ctx->nb_streams;
2411 2412
2412 if ((err = avformat_find_stream_info(fmt_ctx, opts)) < 0) {2413 err = avformat_find_stream_info(fmt_ctx, opts);
2413 print_error(filename, err);2414
2414 return err;
2415 }
2416 for (i = 0; i < orig_nb_streams; i++)2415 for (i = 0; i < orig_nb_streams; i++)
2417 av_dict_free(&opts[i]);2416 av_dict_free(&opts[i]);
2418 av_freep(&opts);2417 av_freep(&opts);
2419 2418
2419 if (err < 0) {
2420 print_error(filename, err);
2421 return err;
2422 }
2423
2420 av_dump_format(fmt_ctx, 0, filename, 0);2424 av_dump_format(fmt_ctx, 0, filename, 0);
2421 2425
2422 /* bind a decoder to each input stream */2426 /* bind a decoder to each input stream */
@@ -2466,7 +2470,7 @@ static void close_input_file(AVFormatContext **ctx_ptr) · 43 unmodified lines
2466 2470
2467static int probe_file(WriterContext *wctx, const char *filename)2471static int probe_file(WriterContext *wctx, const char *filename)
2468{2472{
2469 AVFormatContext *fmt_ctx;2473 AVFormatContext *fmt_ctx = NULL;
2470 int ret, i;2474 int ret, i;
2471 int section_id;2475 int section_id;
2472 2476
@@ -2475,7 +2479,7 @@ static int probe_file(WriterContext *wctx, const char *filename) · 2 unmodified lines
2475 2479
2476 ret = open_input_file(&fmt_ctx, filename);2480 ret = open_input_file(&fmt_ctx, filename);
2477 if (ret < 0)2481 if (ret < 0)
2478 return ret;2482 goto end;
2479 2483
2480#define CHECK_END if (ret < 0) goto end2484#define CHECK_END if (ret < 0) goto end
2481 2485
@@ -2533,7 +2537,8 @@ static int probe_file(WriterContext *wctx, const char *filename) · 51 unmodified lines
2533 }2537 }
2534 2538
2535end:2539end:
2536 close_input_file(&fmt_ctx);2540 if (fmt_ctx)
2541 close_input_file(&fmt_ctx);
2537 av_freep(&nb_streams_frames);2542 av_freep(&nb_streams_frames);
2538 av_freep(&nb_streams_packets);2543 av_freep(&nb_streams_packets);
2539 av_freep(&selected_streams);2544 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