From 8ae35c160692b18ac701edea43cfac675ca18bec Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 28 Mar 2013 16:48:41 +0100 Subject: 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. --- openbsc/src/osmo-bsc/osmo_bsc_ctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'openbsc/src/osmo-bsc/osmo_bsc_ctrl.c') 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 ,(invalid|fix2d|fix3d),,,"); - return 1; + talloc_free(tmp); + cmd->reply = talloc_strdup(cmd, "The format is ,(invalid|fix2d|fix3d),,,"); + return 1; } CTRL_CMD_DEFINE(bts_rf_state, "rf_state"); -- cgit v1.2.3