From 5fa854fdeb880fa70c19e2bedce754aab245be37 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 12 Jul 2022 21:02:09 -0700 Subject: [PATCH] pathplan make_polyline: fix unchecked allocation failure --- lib/pathplan/util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pathplan/util.c b/lib/pathplan/util.c index 19b563146..c70db2116 100644 --- a/lib/pathplan/util.c +++ b/lib/pathplan/util.c @@ -10,11 +10,10 @@ #include +#include #include #include -#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; } -- 2.40.0