]> granicus.if.org Git - graphviz/commitdiff
tclpkg buildBindings: fix incorrect allocation calculations
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 15 Jan 2023 04:11:12 +0000 (20:11 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 15 Jan 2023 21:12:50 +0000 (13:12 -0800)
From context, these appear to be attempting to account for the trailing '\0'.
But they allocate one too many bytes.

tclpkg/tclpathplan/tclpathplan.c

index 34a3aa5229b3bf9c26a395601808682079aceac5..d9d737e1890d2739a05bef42fb7c6af689452077 100644 (file)
@@ -226,7 +226,7 @@ static char *buildBindings(char *s1, char *s2)
        } else {
            l = strlen(s2) - 1;
            if (l) {
-               s3 = malloc(l + 2);
+               s3 = malloc(l + 1);
                strcpy(s3, s2 + 1);
            } else {
                s3 = NULL;
@@ -236,7 +236,7 @@ static char *buildBindings(char *s1, char *s2)
        free(s1);
        l = strlen(s2);
        if (l) {
-           s3 = malloc(l + 2);
+           s3 = malloc(l + 1);
            strcpy(s3, s2);
        } else {
            s3 = NULL;