]> granicus.if.org Git - graphviz/commitdiff
Fix memory leaks in Multilevel_(MQ|Modularity)_Clustering_establish
authorAlex Henrie <alexhenrie24@gmail.com>
Thu, 7 Jan 2021 03:35:57 +0000 (20:35 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 23 Jan 2021 23:51:14 +0000 (15:51 -0800)
lib/sparse/clustering.c
lib/sparse/mq.c

index 86fe04e29a2ab0457937879b22e72c41c64b509a..ae4eeb33a66373383e0fa4d564f032f9a482b6d2 100644 (file)
@@ -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;
index 5fb0658d8778808a6bfddae20c9c0c62706f5736..bdf40575f49c038421cdf9f4a67d2375306a00d1 100644 (file)
@@ -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;