From: Matthew Fernandez Date: Sun, 15 Jan 2023 04:15:30 +0000 (-0800) Subject: tclpkg buildBindings: swap unchecked allocation for agxbuf X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=223f22d1c0276afce09f6065aed58f1b6775f7ee;p=graphviz tclpkg buildBindings: swap unchecked allocation for agxbuf Apart from fixing an unchecked allocation, this is shorter with fewer things to worry about. --- diff --git a/tclpkg/tclpathplan/tclpathplan.c b/tclpkg/tclpathplan/tclpathplan.c index d9d737e18..6ef9aec01 100644 --- a/tclpkg/tclpathplan/tclpathplan.c +++ b/tclpkg/tclpathplan/tclpathplan.c @@ -31,6 +31,7 @@ #include #include +#include #include "makecw.h" #include #include @@ -215,11 +216,10 @@ static char *buildBindings(char *s1, char *s2) if (s1) { l = strlen(s2) - 1; if (l) { - s3 = malloc(strlen(s1) + l + 2); - strcpy(s3, s1); - strcat(s3, "\n"); - strcat(s3, s2 + 1); + agxbuf new = {0}; + agxbprint(&new, "%s\n%s", s1, s2 + 1); free(s1); + return agxbdisown(&new); } else { s3 = s1; }