Review at  https://gerrit.osmocom.org/7749

bsc_nat: ctrl: fix memleak on reply receival

Change-Id: I146c4a561b0cd62779d60da3b55b96e24438bd89
---
M openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
1 file changed, 3 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/49/7749/1

diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c 
b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
index 128ea65..738ac87 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -102,7 +102,7 @@
 {
        struct ctrl_cmd *cmd;
        struct bsc_cmd_list *pending;
-       char *var, *id;
+       char *var;
 
        cmd = ctrl_cmd_parse(bsc, msg);
        msgb_free(msg);
@@ -142,13 +142,12 @@
                /* Find the pending command */
                pending = bsc_get_pending(bsc, cmd->id);
                if (pending) {
-                       id = talloc_strdup(cmd, pending->cmd->id);
-                       if (!id) {
+                       osmo_talloc_replace_string(cmd, &cmd->id, 
pending->cmd->id);
+                       if (!cmd->id) {
                                cmd->type = CTRL_TYPE_ERROR;
                                cmd->reply = "OOM";
                                goto err;
                        }
-                       cmd->id = id;
                        ctrl_cmd_send(&pending->ccon->write_queue, cmd);
                        bsc_nat_ctrl_del_pending(pending);
                } else {

-- 
To view, visit https://gerrit.osmocom.org/7749
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I146c4a561b0cd62779d60da3b55b96e24438bd89
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to