From: Matthew Fernandez Date: Sun, 15 Jan 2023 04:11:12 +0000 (-0800) Subject: tclpkg buildBindings: fix incorrect allocation calculations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43e1cd0ec9473290ae105541bfdf934a0cfc0db3;p=graphviz tclpkg buildBindings: fix incorrect allocation calculations From context, these appear to be attempting to account for the trailing '\0'. But they allocate one too many bytes. --- diff --git a/tclpkg/tclpathplan/tclpathplan.c b/tclpkg/tclpathplan/tclpathplan.c index 34a3aa522..d9d737e18 100644 --- a/tclpkg/tclpathplan/tclpathplan.c +++ b/tclpkg/tclpathplan/tclpathplan.c @@ -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;