]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: Cleanup memory leak 12436/head
authorDonald Sharp <sharpd@nvidia.com>
Sat, 3 Dec 2022 12:16:36 +0000 (07:16 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 5 Dec 2022 13:50:24 +0000 (08:50 -0500)
When multiple daemons report a exit line for the same
node, vtysh was just dropping the previous pointer.
Ensure that we free it first.

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

index ac0cdc6ffd3d06ef6d947e002bdeef72ece5a845..ac32f0a774bdb851e507ad6050cfe63a92ab2998 100644 (file)
@@ -348,9 +348,13 @@ void vtysh_config_parse_line(void *arg, const char *line)
                break;
        default:
                if (strncmp(line, "exit", strlen("exit")) == 0) {
-                       if (config)
+                       if (config) {
+                               if (config->exit)
+                                       XFREE(MTYPE_VTYSH_CONFIG_LINE,
+                                             config->exit);
                                config->exit =
                                        XSTRDUP(MTYPE_VTYSH_CONFIG_LINE, line);
+                       }
                } else if (strncmp(line, "interface", strlen("interface")) == 0)
                        config = config_get(INTERFACE_NODE, line);
                else if (strncmp(line, "pseudowire", strlen("pseudowire")) == 0)