]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Free memory leak in error path in clippy
authorMark Stapp <mjs@voltanet.io>
Fri, 26 Feb 2021 16:21:04 +0000 (11:21 -0500)
committerMark Stapp <mjs@voltanet.io>
Fri, 26 Feb 2021 16:21:04 +0000 (11:21 -0500)
When running clippy, the main function in it's
error path could leak the memory pointed to by name.
Fix this.  This was/is reported by clang SA.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/clippy.c

index fd0a9eebc0d46837d1449308fb18b12d2cf0a857..b67662880e93794f7f53252b190f062e40e37da2 100644 (file)
@@ -68,6 +68,8 @@ int main(int argc, char **argv)
                fp = fopen(pyfile, "r");
                if (!fp) {
                        fprintf(stderr, "%s: %s\n", pyfile, strerror(errno));
+
+                       free(name);
                        return 1;
                }
        } else {
@@ -86,6 +88,8 @@ int main(int argc, char **argv)
        if (PyRun_AnyFile(fp, pyfile)) {
                if (PyErr_Occurred())
                        PyErr_Print();
+
+               free(name);
                return 1;
        }
        Py_Finalize();