diff options
author | Luca Deri <lucaderi@users.noreply.github.com> | 2020-07-07 17:18:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 17:18:03 +0200 |
commit | 0c80e6ee3bed251e42c9eb3f9ddb4ce169061d1f (patch) | |
tree | 33e90dff0d8578d8ea6d03cfd3e539bf31544e20 | |
parent | 1c60c22893e465da75b825ce4bab80ca018e9104 (diff) | |
parent | e308e59002539a989e87c72bdb462b9652e304b3 (diff) |
Merge pull request #954 from lnslbrty/fix/memleak-cluster-bins
fixed memory leak in ndpi_cluster_bins / binUnitTest
-rw-r--r-- | example/ndpiReader.c | 2 | ||||
-rw-r--r-- | src/lib/ndpi_analyze.c | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 39e36f248..a3e35bd4f 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -3163,6 +3163,8 @@ static void binUnitTest() { for(i=0; i<num_bins; i++) ndpi_free_bin(&bins[i]); + + free(bins); } /* *********************************************** */ diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index 74adbb2c9..07fc09362 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -486,7 +486,7 @@ int ndpi_cluster_bins(struct ndpi_bin *bins, u_int16_t num_bins, if(num_clusters > num_bins) return(-1); - if((centroids = (struct ndpi_bin*)malloc(sizeof(struct ndpi_bin)*num_clusters)) == NULL) + if((centroids = (struct ndpi_bin*)ndpi_malloc(sizeof(struct ndpi_bin)*num_clusters)) == NULL) return(-2); else { for(i=0; i<num_clusters; i++) @@ -571,6 +571,8 @@ int ndpi_cluster_bins(struct ndpi_bin *bins, u_int16_t num_bins, for(i=0; i<num_clusters; i++) ndpi_free_bin(¢roids[i]); + ndpi_free(centroids); + return(0); } |