tshark: free exp_pdu_filename and capture_opts->save_file

valgrind --tool=memcheck --leak-check=full ./run/tshark -r sctp.pcap -U "OSI layer 3" -w exported.pcap

13 bytes in 1 blocks are definitely lost in loss record 20 of 93
   at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
   by 0xB27B3C5: g_malloc (gmem.c:99)
   by 0xB294D22: g_strdup (gstrfuncs.c:363)
   by 0x117B5D: capture_opts_add_opt (capture_opts.c:889)
   by 0x118C0E: main (tshark.c:1112)

Change-Id: I9b794015aa4d2626b43a5743864c2d732c6acaa1
Reviewed-on: https://code.wireshark.org/review/29125
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Vasil Velichkov 2018-08-09 03:38:36 +03:00 committed by Gerald Combs
parent b1b98051b2
commit 787d61c0a4
2 changed files with 6 additions and 2 deletions

View File

@ -140,6 +140,7 @@ capture_opts_cleanup(capture_options *capture_opts)
g_array_free(capture_opts->all_ifaces, TRUE);
capture_opts->all_ifaces = NULL;
}
g_free(capture_opts->save_file);
}
/* log content of capture_opts */

View File

@ -728,7 +728,7 @@ main(int argc, char *argv[])
int log_flags;
gchar *output_only = NULL;
gchar *volatile pdu_export_arg = NULL;
const char *volatile exp_pdu_filename = NULL;
char *volatile exp_pdu_filename = NULL;
exp_pdu_t exp_pdu_tap_data;
#ifdef HAVE_JSONGLIB
const gchar* elastic_mapping_filter = NULL;
@ -1113,7 +1113,7 @@ main(int argc, char *argv[])
* Output file name, if we're reading a file and writing to another
* file.
*/
output_file_name = optarg;
output_file_name = g_strdup(optarg);
} else {
capture_option_specified = TRUE;
arg_error = TRUE;
@ -2078,6 +2078,7 @@ main(int argc, char *argv[])
exit_status = 2;
}
g_free(pdu_export_arg);
g_free(exp_pdu_filename);
}
} else {
tshark_debug("tshark: no capture file specified");
@ -2249,6 +2250,8 @@ clean_exit:
destroy_print_stream(print_stream);
#ifdef HAVE_LIBPCAP
capture_opts_cleanup(&global_capture_opts);
#else
g_free(output_file_name);
#endif
col_cleanup(&cfile.cinfo);
free_filter_lists();