diff options
author | Dario Lombardo <lomato@gmail.com> | 2017-02-21 14:28:57 +0100 |
---|---|---|
committer | Dario Lombardo <lomato@gmail.com> | 2017-02-28 14:56:36 +0000 |
commit | 146b6b824da171f457198797def5083d2fa90a0c (patch) | |
tree | cfe692a1fa97b412d8d66685f14bb15aa8f71386 | |
parent | 26e62dfad07a02efc03e4c08c3c6b08e5c5d2076 (diff) |
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 <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
-rw-r--r-- | text2pcap.c | 9 | ||||
-rw-r--r-- | 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 /* |