aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2019-01-20 23:47:24 +0100
committerLuca Deri <deri@ntop.org>2019-01-20 23:47:24 +0100
commitefa96da3e0d7c07d7862aeaeddc7ef46d62f8ded (patch)
tree0254f5d9fc6c2e8a59e88547a478abb691d5e3f3 /example
parentb9ae65014634237691aeef5ddc6bafb13fb26144 (diff)
Fixes #657
Diffstat (limited to 'example')
-rw-r--r--example/ndpiReader.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 3f030265c..9cb4ad6f6 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -913,10 +913,11 @@ static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int dept
struct ndpi_flow_info *flow = *(struct ndpi_flow_info **) node;
u_int16_t thread_id = *((u_int16_t *) user_data);
- if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */
- if((!flow->detection_completed) && flow->ndpi_flow)
+ if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */
+ if((!flow->detection_completed) && flow->ndpi_flow) {
flow->detected_protocol = ndpi_detection_giveup(ndpi_thread_info[0].workflow->ndpi_struct, flow->ndpi_flow, enable_protocol_guess);
-
+ }
+
process_ndpi_collected_info(ndpi_thread_info[thread_id].workflow, flow);
ndpi_thread_info[thread_id].workflow->stats.protocol_counter[flow->detected_protocol.app_protocol] += flow->src2dst_packets + flow->dst2src_packets;
@@ -2488,8 +2489,7 @@ static void ndpi_process_packet(u_char *args,
if(memcmp(packet, packet_checked, header->caplen) != 0)
printf("INTERNAL ERROR: ingress packet was modified by nDPI: this should not happen [thread_id=%u, packetId=%lu, caplen=%u]\n",
thread_id, (unsigned long)ndpi_thread_info[thread_id].workflow->stats.raw_packet_count, header->caplen);
- free(packet_checked);
-
+
if((pcap_end.tv_sec-pcap_start.tv_sec) > pcap_analysis_duration) {
int i;
u_int64_t processing_time_usec, setup_time_usec;
@@ -2513,6 +2513,12 @@ static void ndpi_process_packet(u_char *args,
memcpy(&begin, &end, sizeof(begin));
memcpy(&pcap_start, &pcap_end, sizeof(pcap_start));
}
+
+ /*
+ Leave the free as last statement to avoid crashes when ndpi_detection_giveup()
+ is called above by printResults()
+ */
+ free(packet_checked);
}