]> granicus.if.org Git - graphviz/commitdiff
tclpkg buildBindings: swap unchecked allocation for agxbuf
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 15 Jan 2023 04:15:30 +0000 (20:15 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 15 Jan 2023 21:12:50 +0000 (13:12 -0800)
Apart from fixing an unchecked allocation, this is shorter with fewer things to
worry about.

tclpkg/tclpathplan/tclpathplan.c

index d9d737e1890d2739a05bef42fb7c6af689452077..6ef9aec01b30d9dd992cc7962ace82570c9efddf 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <inttypes.h>
 #include <assert.h>
+#include <cgraph/agxbuf.h>
 #include "makecw.h"
 #include <math.h>
 #include <pathplan/pathutil.h>
@@ -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;
            }