]> granicus.if.org Git - graphviz/commitdiff
sparse SparseMatrix_level_sets_internal: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 15 Sep 2022 00:47:27 +0000 (17:47 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 20 Sep 2022 14:36:59 +0000 (07:36 -0700)
lib/sparse/SparseMatrix.c

index 806063b1295fcfd7702e699a1c515b83c491e756..8592bb529314efbd5cdff540c7e8dc753dac35d7 100644 (file)
@@ -12,6 +12,7 @@
 #include <string.h>
 #include <math.h>
 #include <assert.h>
+#include <cgraph/alloc.h>
 #include <common/memory.h>
 #include <common/arith.h>
 #include <limits.h>
@@ -1787,7 +1788,7 @@ static void SparseMatrix_level_sets_internal(int khops, SparseMatrix A, int root
   if (!(*levelset_ptr)) *levelset_ptr = MALLOC(sizeof(int)*((size_t)(m+2)));
   if (!(*levelset)) *levelset = MALLOC(sizeof(int)*((size_t)m));
   if (!(*mask)) {
-    *mask = malloc(sizeof(int)*((size_t)m));
+    *mask = gv_calloc((size_t)m, sizeof(int));
     for (i = 0; i < m; i++) (*mask)[i] = UNMASKED;
   }