]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Free memory leak in error path in clippy
authorDonald Sharp <sharpd@nvidia.com>
Sat, 20 Feb 2021 12:38:06 +0000 (07:38 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Sat, 20 Feb 2021 12:40:01 +0000 (07:40 -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 b52c48ec920a1c5228c75ca2ff79050c6da05ed6..6223697ae98589db84fe2723c1d5bb7f1e7e86f9 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();