aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorNardi Ivan <nardi.ivan@gmail.com>2020-07-07 10:26:11 +0200
committerNardi Ivan <nardi.ivan@gmail.com>2020-07-07 10:27:57 +0200
commit030f3f3d48184133a6647108c156787fb3f39b58 (patch)
tree53b49170724d245807f70eed1d4dcae68fff5012 /example/ndpiReader.c
parent974c1cc681af5a8faa6e7186a947a76a045b266f (diff)
Fix a memory leak
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 1b20ac2f9..4be142d28 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -384,7 +384,9 @@ static void help(u_int long_help) {
" -V <1-4> | nDPI logging level\n"
" | 1 - trace, 2 - debug, 3 - full debug\n"
" | >3 - full debug + log enabled for all protocols (i.e. '-u all')\n"
- " -u proto|num[,...] | Enable logging only for such protocol(s)\n"
+ " -u all|proto|num[,...] | Enable logging only for such protocol(s)\n"
+ " | If this flag is present multiple times (directly, or via '-V'),\n"
+ " | only the last instance will be considered\n"
" -T <num> | Max number of TCP processed packets before giving up [default: %u]\n"
" -U <num> | Max number of UDP processed packets before giving up [default: %u]\n"
,
@@ -736,11 +738,13 @@ static void parseOptions(int argc, char **argv) {
if(nDPI_LogLevel < 0) nDPI_LogLevel = 0;
if(nDPI_LogLevel > 3) {
nDPI_LogLevel = 3;
+ free(_debug_protocols);
_debug_protocols = strdup("all");
}
break;
case 'u':
+ free(_debug_protocols);
_debug_protocols = strdup(optarg);
break;
@@ -819,6 +823,7 @@ static void parseOptions(int argc, char **argv) {
case '8':
nDPI_LogLevel = NDPI_LOG_DEBUG_EXTRA;
+ free(_debug_protocols);
_debug_protocols = strdup("all");
break;
@@ -3525,6 +3530,7 @@ int orginal_main(int argc, char **argv) {
if(extcap_fifo_h) pcap_close(extcap_fifo_h);
if(ndpi_info_mod) ndpi_exit_detection_module(ndpi_info_mod);
if(csv_fp) fclose(csv_fp);
+ free(_debug_protocols);
return 0;
}