]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: mgmtd: fix memleaks
authorChristian Hopps <chopps@labn.net>
Sat, 20 May 2023 03:12:33 +0000 (23:12 -0400)
committerChristian Hopps <chopps@labn.net>
Tue, 30 May 2023 06:10:20 +0000 (02:10 -0400)
Signed-off-by: Christian Hopps <chopps@labn.net>
lib/mgmt_be_client.c
lib/vty.c
mgmtd/mgmt_txn.c

index 2445fe9d07ebcf97b9462b81fb25cb2b1361890c..534dc43405bf317e24ee3c37fc24b0e9e97ce735 100644 (file)
@@ -1072,6 +1072,7 @@ void mgmt_be_client_lib_destroy(void)
        msg_client_cleanup(&client_ctx->client);
        mgmt_be_cleanup_all_txns(client_ctx);
        mgmt_be_txns_fini(&client_ctx->txn_head);
+       nb_config_free(client_ctx->candidate_config);
 
        memset(client_ctx, 0, sizeof(*client_ctx));
 }
index 1e17f18a2332b967ca216dd1175e25c1ec1c01c7..51c2ebdc55dc4805143431c51a4f157357715fdc 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2472,6 +2472,7 @@ void vty_close(struct vty *vty)
        if (vty->fd == STDIN_FILENO)
                was_stdio = true;
 
+       XFREE(MTYPE_TMP, vty->pending_cmds_buf);
        XFREE(MTYPE_VTY, vty->buf);
 
        if (vty->error) {
index 93466a2b39e18af63c2e70075c16e02425dc3e54..ef5e7e8e324a6689f5a6d9c2cb1eb680df5b4960 100644 (file)
@@ -1090,8 +1090,8 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
                                &cfg_btch->data[cfg_btch->num_cfg_data]);
                        cfg_btch->cfg_data[cfg_btch->num_cfg_data].data =
                                &cfg_btch->data[cfg_btch->num_cfg_data];
-                       cfg_btch->data[cfg_btch->num_cfg_data].xpath = xpath;
-                       xpath = NULL;
+                       cfg_btch->data[cfg_btch->num_cfg_data].xpath =
+                               strdup(xpath);
 
                        mgmt_yang_data_value_init(
                                &cfg_btch->value[cfg_btch->num_cfg_data]);
@@ -1127,6 +1127,9 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
                                 xpath);
                        MGMTD_TXN_ERR("***** %s", err_buf);
                }
+
+               free(xpath);
+               xpath = NULL;
        }
 
        cmtcfg_req->cmt_stats->last_batch_cnt = num_chgs;