]> granicus.if.org Git - graphviz/commitdiff
smyrna add_selpoly: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 01:02:37 +0000 (18:02 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 01:06:29 +0000 (18:06 -0700)
cmd/smyrna/selectionfuncs.c

index 184b44d013f081d9e3e1f2ee9622f4a5a1126120..04d9e23c037c3ed9215e4b2408dbe4c9ff6921e4 100644 (file)
@@ -8,6 +8,7 @@
  * Contributors: Details at https://graphviz.org
  *************************************************************************/
 
+#include <cgraph/alloc.h>
 #include <limits.h>
 #include "selectionfuncs.h"
 #include "topviewfuncs.h"
@@ -272,8 +273,9 @@ void add_selpoly(Agraph_t* g,glCompPoly* selPoly,glCompPoint pt)
 {
     if(!close_poly(selPoly,pt))
     {
+       selPoly->pts = gv_recalloc(selPoly->pts, selPoly->cnt, selPoly->cnt + 1,
+                                  sizeof(glCompPoint));
        selPoly->cnt ++;
-       selPoly->pts=realloc(selPoly->pts,sizeof(glCompPoint)*selPoly->cnt);
        selPoly->pts[selPoly->cnt-1].x=pt.x;
        selPoly->pts[selPoly->cnt-1].y=pt.y;
        selPoly->pts[selPoly->cnt-1].z=0;