From a60854bae683c3b16c023d03b02bdcd139ca0bfd Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Mon, 6 Apr 2020 17:58:20 +0200 Subject: Fix some debug messages --- example/ndpiReader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index bc9df4294..6457cbf09 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -1117,7 +1117,8 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa flowGetBDMeanandVariance(flow); } - fprintf(csv_fp, "\n"); + if(csv_fp) + fprintf(csv_fp, "\n"); return; } -- cgit v1.2.3 From e84563f9710ca1996eb7428a22a058527e604431 Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Wed, 8 Apr 2020 15:13:48 +0200 Subject: ndpiReader: fix memory leak in idle sessions purging --- example/ndpiReader.c | 1 + example/reader_util.c | 10 ++++++++-- example/reader_util.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 6457cbf09..91eca9bd2 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -1753,6 +1753,7 @@ static void node_idle_scan_walker(const void *node, ndpi_VISIT which, int depth, ndpi_free_flow_info_half(flow); ndpi_free_flow_data_analysis(flow); + ndpi_free_flow_tls_data(flow); ndpi_thread_info[thread_id].workflow->stats.ndpi_flow_count--; /* adding to a queue (we can't delete it from the tree inline ) */ diff --git a/example/reader_util.c b/example/reader_util.c index dd1a15d2f..97aa940bd 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -456,6 +456,14 @@ void ndpi_flow_info_freer(void *node) { ndpi_free_flow_info_half(flow); ndpi_free_flow_data_analysis(flow); + ndpi_free_flow_tls_data(flow); + + ndpi_free(flow); +} + +/* ***************************************************** */ + +void ndpi_free_flow_tls_data(struct ndpi_flow_info *flow) { if(flow->ssh_tls.server_names) { ndpi_free(flow->ssh_tls.server_names); @@ -471,8 +479,6 @@ void ndpi_flow_info_freer(void *node) { ndpi_free(flow->ssh_tls.tls_supported_versions); flow->ssh_tls.tls_supported_versions = NULL; } - - ndpi_free(flow); } /* ***************************************************** */ diff --git a/example/reader_util.h b/example/reader_util.h index 942c1f361..c726c9672 100644 --- a/example/reader_util.h +++ b/example/reader_util.h @@ -318,6 +318,7 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl u_int32_t ethernet_crc32(const void* data, size_t n_bytes); void ndpi_flow_info_freer(void *node); void ndpi_free_flow_data_analysis(struct ndpi_flow_info *flow); +void ndpi_free_flow_tls_data(struct ndpi_flow_info *flow); const char* print_cipher_id(u_int32_t cipher); float ndpi_flow_get_byte_count_entropy(const uint32_t byte_count[256], unsigned int num_bytes); -- cgit v1.2.3