]> granicus.if.org Git - graphviz/commitdiff
pathplan make_polyline: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 13 Jul 2022 04:02:09 +0000 (21:02 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 22 Jul 2022 00:41:58 +0000 (17:41 -0700)
lib/pathplan/util.c

index 19b5631460369816de5b0ff1059c3fda0bfd16de..c70db211631f92e5acedfdf27677bd950c350aef 100644 (file)
 
 
 #include <assert.h>
+#include <cgraph/alloc.h>
 #include <stdlib.h>
 #include <pathplan/pathutil.h>
 
-#define ALLOC(size,ptr,type) realloc(ptr,(size)*sizeof(type))
-
 void freePath(Ppolyline_t* p)
 {
     free(p->ps);
@@ -63,7 +62,7 @@ make_polyline(Ppolyline_t line, Ppolyline_t* sline)
     int npts = 4 + 3*(line.pn-2);
 
     if (npts > isz) {
-       ispline = ALLOC((size_t)npts, ispline, Ppoint_t);
+       ispline = gv_recalloc(ispline, (size_t)isz, (size_t)npts, sizeof(Ppoint_t));
        isz = npts;
     }