From 0d68f8ab5d92a9021b91702913cc973eb98a9235 Mon Sep 17 00:00:00 2001 From: Michele Campus Date: Sun, 19 Jul 2015 01:21:37 +0200 Subject: added free for flow in get_ndpi_flow - deleted dead part in ndpi_typedef.c --- example/ndpiReader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'example') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 4ef08091a..c11c0c50d 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -575,6 +575,7 @@ static void free_ndpi_flow(struct ndpi_flow *flow) { if(flow->ndpi_flow) { ndpi_free_flow(flow->ndpi_flow); flow->ndpi_flow = NULL; } if(flow->src_id) { ndpi_free(flow->src_id); flow->src_id = NULL; } if(flow->dst_id) { ndpi_free(flow->dst_id); flow->dst_id = NULL; } + } /* ***************************************************** */ @@ -845,18 +846,21 @@ static struct ndpi_flow *get_ndpi_flow(u_int16_t thread_id, if((newflow->ndpi_flow = malloc_wrapper(size_flow_struct)) == NULL) { printf("[NDPI] %s(2): not enough memory\n", __FUNCTION__); + free(newflow); return(NULL); } else memset(newflow->ndpi_flow, 0, size_flow_struct); if((newflow->src_id = malloc_wrapper(size_id_struct)) == NULL) { printf("[NDPI] %s(3): not enough memory\n", __FUNCTION__); + free(newflow); return(NULL); } else memset(newflow->src_id, 0, size_id_struct); if((newflow->dst_id = malloc_wrapper(size_id_struct)) == NULL) { printf("[NDPI] %s(4): not enough memory\n", __FUNCTION__); + free(newflow); return(NULL); } else memset(newflow->dst_id, 0, size_id_struct); @@ -868,7 +872,7 @@ static struct ndpi_flow *get_ndpi_flow(u_int16_t thread_id, // printFlow(thread_id, newflow); - return(newflow); + return newflow ; } } else { struct ndpi_flow *flow = *(struct ndpi_flow**)ret; -- cgit v1.2.3