aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorOleg A. Arkhangelsky <sysoleg@yandex.ru>2019-10-29 21:11:31 +0300
committerOleg A. Arkhangelsky <sysoleg@yandex.ru>2019-10-29 21:11:31 +0300
commit9f5e5b90e5f460a9038f5e7ec2d8672049f861c1 (patch)
treed0756aba5c74d0efbc62f033894e8a4e03c01693 /example
parentd2f04f5bdfe986082ca5e5f479a99e4c24a5a898 (diff)
Don't leak memory in live capture mode
Diffstat (limited to 'example')
-rw-r--r--example/ndpiReader.c1
-rw-r--r--example/reader_util.c10
-rw-r--r--example/reader_util.h1
3 files changed, 10 insertions, 2 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index a5481d342..5efa7bdc8 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -1784,6 +1784,7 @@ static void node_idle_scan_walker(const void *node, ndpi_VISIT which, int depth,
undetected_flows_deleted = 1;
ndpi_free_flow_info_half(flow);
+ ndpi_free_flow_data_analysis(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 6cb150d87..be150ecf8 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -457,6 +457,14 @@ void ndpi_flow_info_freer(void *node) {
ndpi_free_flow_info_half(flow);
+ ndpi_free_flow_data_analysis(flow);
+
+ ndpi_free(flow);
+}
+
+/* ***************************************************** */
+
+void ndpi_free_flow_data_analysis(struct ndpi_flow_info *flow) {
if(flow->iat_c_to_s) ndpi_free_data_analysis(flow->iat_c_to_s);
if(flow->iat_s_to_c) ndpi_free_data_analysis(flow->iat_s_to_c);
@@ -464,8 +472,6 @@ void ndpi_flow_info_freer(void *node) {
if(flow->pktlen_s_to_c) ndpi_free_data_analysis(flow->pktlen_s_to_c);
if(flow->iat_flow) ndpi_free_data_analysis(flow->iat_flow);
-
- ndpi_free(flow);
}
/* ***************************************************** */
diff --git a/example/reader_util.h b/example/reader_util.h
index 3374f993f..9165ee1e6 100644
--- a/example/reader_util.h
+++ b/example/reader_util.h
@@ -299,6 +299,7 @@ int ndpi_workflow_node_cmp(const void *a, const void *b);
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow);
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);
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);