diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2013-03-28 16:48:41 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2013-03-28 17:13:01 +0100 |
commit | 8ae35c160692b18ac701edea43cfac675ca18bec (patch) | |
tree | f77e7d4a06cdc9839fc4b4a8a34ed80e2c9ce0b1 /openbsc/src/osmo-bsc/osmo_bsc_ctrl.c | |
parent | 0c908b6e725dde5f0fa30946fc0eb41fb4a6ca47 (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/src/osmo-bsc/osmo_bsc_ctrl.c')
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_ctrl.c | 7 |
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"); |