[PATCH] osmo-bsc[master]: bsc_nat: ctrl: fix memleak on reply receival

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Wed Apr 11 11:17:04 UTC 2018


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

bsc_nat: ctrl: fix memleak on reply receival

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/48/7748/1

diff --git a/src/osmo-bsc_nat/bsc_nat_ctrl.c b/src/osmo-bsc_nat/bsc_nat_ctrl.c
index 93cdff3..9450741 100644
--- a/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -103,7 +103,7 @@
 {
 	struct ctrl_cmd *cmd;
 	struct bsc_cmd_list *pending;
-	char *var, *id;
+	char *var;
 
 	cmd = ctrl_cmd_parse(bsc, msg);
 	msgb_free(msg);
@@ -143,13 +143,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/7748
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I163d4d12d8656628dc88ff3e59a4c3e53b760a0c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list