]> granicus.if.org Git - graphviz/commitdiff
fix memory leak in edgepaint command line parsing
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 18 Jul 2021 20:25:09 +0000 (13:25 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Jul 2021 00:18:37 +0000 (17:18 -0700)
When passing the option `-lightness` multiple times, pointers to previous
lightness strings would be overwritten and lost. This is unlikely to have had a
significant effect. Related to #1971.

cmd/edgepaint/edgepaintmain.c

index 594356cd1c25c621315f2726ea8de6019fae9f74..452e1cb2ee0138a1757a935704616e837c6341f1 100644 (file)
@@ -164,6 +164,7 @@ static void init(int argc, char *argv[], real *angle, real *accuracy, char **inf
          fprintf(stderr,"invalid -lightness=%s option.\n", optarg + 9);
          usage(cmd, 1);
        }
+       free(*lightness);
        *lightness = malloc(sizeof(char)*10);
        strcpy(*lightness, optarg + 9);
       } else {