From 146b6b824da171f457198797def5083d2fa90a0c Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Tue, 21 Feb 2017 14:28:57 +0100 Subject: text2pcap: free memory on exit. Make also text2pcap_lex_destroy() public to be called from main. Change-Id: I360c3dd3991d027afe6e4542ea5f9680e92f92cf Reviewed-on: https://code.wireshark.org/review/20226 Reviewed-by: Michael Mann Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo --- text2pcap.c | 9 +++++---- text2pcap.h | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/text2pcap.c b/text2pcap.c index 851cb299b3..dd58e722db 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -236,10 +236,10 @@ static struct tm timecode_default; static guint8* pkt_lnstart; /* Input file */ -static const char *input_filename; +static char *input_filename; static FILE *input_file = NULL; /* Output file */ -static const char *output_filename; +static char *output_filename; static FILE *output_file = NULL; /* Offset base to parse */ @@ -1779,7 +1779,7 @@ parse_options (int argc, char *argv[]) } if (strcmp(argv[optind], "-") != 0) { - input_filename = g_strdup(argv[optind]); + input_filename = argv[optind]; input_file = ws_fopen(input_filename, "rb"); if (!input_file) { fprintf(stderr, "Cannot open file [%s] for reading: %s\n", @@ -1793,7 +1793,7 @@ parse_options (int argc, char *argv[]) if (strcmp(argv[optind+1], "-") != 0) { /* Write to a file. Open the file, in binary mode. */ - output_filename = g_strdup(argv[optind+1]); + output_filename = argv[optind+1]; output_file = ws_fopen(output_filename, "wb"); if (!output_file) { fprintf(stderr, "Cannot open file [%s] for writing: %s\n", @@ -1915,6 +1915,7 @@ main(int argc, char *argv[]) bytes_written, (bytes_written == 1) ? "" : "s"); } clean_exit: + text2pcap_lex_destroy(); fclose(input_file); fclose(output_file); return ret; diff --git a/text2pcap.h b/text2pcap.h index fd3a46202c..488176d5e1 100644 --- a/text2pcap.h +++ b/text2pcap.h @@ -44,6 +44,8 @@ int parse_token(token_t token, char *str); int text2pcap_lex(void); +int text2pcap_lex_destroy(void); + #endif /* -- cgit v1.2.3