From 61b563bcbf4a65eb8881b2e737c6deb4b4383d90 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Wed, 6 Jan 2021 20:35:57 -0700 Subject: [PATCH 1/3] Fix memory leaks in Multilevel_(MQ|Modularity)_Clustering_establish --- lib/sparse/clustering.c | 10 ++++++++-- lib/sparse/mq.c | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/sparse/clustering.c b/lib/sparse/clustering.c index 86fe04e29a..ae4eeb33a6 100644 --- a/lib/sparse/clustering.c +++ b/lib/sparse/clustering.c @@ -223,9 +223,15 @@ static Multilevel_Modularity_Clustering Multilevel_Modularity_Clustering_establi SparseMatrix_delete(R0); P = SparseMatrix_transpose(R); B = SparseMatrix_multiply(R, A); - if (!B) goto RETURN; + if (!B) { + FREE(deg_new); + goto RETURN; + } cA = SparseMatrix_multiply(B, P); - if (!cA) goto RETURN; + if (!cA) { + FREE(deg_new); + goto RETURN; + } SparseMatrix_delete(B); grid->P = P; grid->R = R; diff --git a/lib/sparse/mq.c b/lib/sparse/mq.c index 5fb0658d87..bdf40575f4 100644 --- a/lib/sparse/mq.c +++ b/lib/sparse/mq.c @@ -471,9 +471,19 @@ static Multilevel_MQ_Clustering Multilevel_MQ_Clustering_establish(Multilevel_MQ SparseMatrix_delete(R0); P = SparseMatrix_transpose(R); B = SparseMatrix_multiply(R, A); - if (!B) goto RETURN; + if (!B) { + FREE(deg_intra_new); + FREE(wgt_new); + FREE(dout_new); + goto RETURN; + } cA = SparseMatrix_multiply(B, P); - if (!cA) goto RETURN; + if (!cA) { + FREE(deg_intra_new); + FREE(wgt_new); + FREE(dout_new); + goto RETURN; + } SparseMatrix_delete(B); grid->P = P; grid->R = R; -- GitLab From f56a99fd699c196ed4572a4d26c49eddf6f0e59a Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Wed, 6 Jan 2021 20:35:57 -0700 Subject: [PATCH 2/3] Fix memory leak in gv_get_ps_fontlist --- plugin/pango/gvgetfontlist_pango.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/pango/gvgetfontlist_pango.c b/plugin/pango/gvgetfontlist_pango.c index c6afc42aac..6bb7bcdfe9 100644 --- a/plugin/pango/gvgetfontlist_pango.c +++ b/plugin/pango/gvgetfontlist_pango.c @@ -407,6 +407,7 @@ static availfont_t *gv_get_ps_fontlist(PangoFontMap * fontmap) } else { gv_afs->fontname = NULL; gv_afs->faces = 0; + free(family_name); } } g_free(families); -- GitLab From c172f695ef873f62f7fad0735aa63817d18407c9 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Sat, 9 Jan 2021 02:02:07 -0700 Subject: [PATCH 3/3] Fix memory leak in make_map_internal --- cmd/gvmap/make_map.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/gvmap/make_map.c b/cmd/gvmap/make_map.c index 04a71aa4b3..480cf98234 100644 --- a/cmd/gvmap/make_map.c +++ b/cmd/gvmap/make_map.c @@ -1891,11 +1891,14 @@ int make_map_internal(int exclude_random, int include_OK_points, xran = MALLOC(sizeof(real)*(*nrandom + 4)*dim2); nz = 0; if (INCLUDE_OK_POINTS){ - int *grouping2; nzok0 = nzok = *nrandom - 1;/* points that are within tolerance of real or artificial points */ - grouping2 = MALLOC(sizeof(int)*(n + *nrandom)); - memcpy(grouping2, grouping, sizeof(int)*n); - grouping = grouping2; + if (grouping == grouping0) { + int *grouping2 = MALLOC(sizeof(int)*(n + *nrandom)); + memcpy(grouping2, grouping, sizeof(int)*n); + grouping = grouping2; + } else { + grouping = REALLOC(grouping, sizeof(int)*(n + *nrandom)); + } } nn = n; -- GitLab