aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-03-28 16:48:41 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-03-28 17:13:01 +0100
commit8ae35c160692b18ac701edea43cfac675ca18bec (patch)
treef77e7d4a06cdc9839fc4b4a8a34ed80e2c9ce0b1 /openbsc
parent0c908b6e725dde5f0fa30946fc0eb41fb4a6ca47 (diff)
bsc-ctrl: Fix a potential memory leak on failed verification
It was possible that the tmp was strduped but not freed, e.g. when the number of commas was not right. It would evenutally be freed at the time the cmd is freed thanks to the talloc hierachy.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_ctrl.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
index 2a035f0e3..c82ffc967 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -359,6 +359,7 @@ static int verify_bts_loc(struct ctrl_cmd *cmd, const char *value, void *data)
lon = atof(lonstr);
height = atof(heightstr);
talloc_free(tmp);
+ tmp = NULL;
if (((tstamp == 0) && (valid != BTS_LOC_FIX_INVALID)) || (lat < -90) || (lat > 90) ||
(lon < -180) || (lon > 180) || (valid < 0)) {
@@ -366,9 +367,11 @@ static int verify_bts_loc(struct ctrl_cmd *cmd, const char *value, void *data)
}
return 0;
+
err:
- cmd->reply = talloc_strdup(cmd, "The format is <unixtime>,(invalid|fix2d|fix3d),<lat>,<lon>,<height>");
- return 1;
+ talloc_free(tmp);
+ cmd->reply = talloc_strdup(cmd, "The format is <unixtime>,(invalid|fix2d|fix3d),<lat>,<lon>,<height>");
+ return 1;
}
CTRL_CMD_DEFINE(bts_rf_state, "rf_state");