From 8cc5cb9f767119f7219c918843893bdeaa98d909 Mon Sep 17 00:00:00 2001 From: ol-andreyizrailev <62878213+ol-andreyizrailev@users.noreply.github.com> Date: Wed, 9 Feb 2022 13:43:10 +0300 Subject: Increment current/total number of active flows on successful flow insertion (#1434) Memory allocation or ndpi_tsearch might fail, so the two values should be incremented only when insertion actually happened. Co-authored-by: Andrey Izrailev --- example/ndpiSimpleIntegration.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'example/ndpiSimpleIntegration.c') diff --git a/example/ndpiSimpleIntegration.c b/example/ndpiSimpleIntegration.c index 57b51450c..303917a1b 100644 --- a/example/ndpiSimpleIntegration.c +++ b/example/ndpiSimpleIntegration.c @@ -776,8 +776,6 @@ static void ndpi_process_packet(uint8_t * const args, return; } - workflow->cur_active_flows++; - workflow->total_active_flows++; memcpy(flow_to_process, &flow, sizeof(*flow_to_process)); flow_to_process->flow_id = __sync_fetch_and_add(&flow_id, 1); @@ -796,6 +794,9 @@ static void ndpi_process_packet(uint8_t * const args, /* Possible Leak, but should not happen as we'd abort earlier. */ return; } + + workflow->cur_active_flows++; + workflow->total_active_flows++; } else { flow_to_process = *(struct nDPI_flow_info **)tree_result; } -- cgit v1.2.3