From 5d88111a142b3c37e92bdd36699a04fd054d27f4 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 22 May 2019 17:46:19 +0200 Subject: Fix some "Null pointer dereference" coverity issues This patch fixes the following CID's: * 1124829 * 1274075 * 1274083 * 1274128 * 1274135 * 1274141 * 1274143 * 1274197 * 1274205 * 1274210 * 1274211 * 1288801 * 1398629 Change-Id: Ia7c86cfab3245b20777ffa296e1a59748040f558 Updates: bz#789278 Signed-off-by: Xavi Hernandez --- xlators/protocol/client/src/client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'xlators/protocol/client') diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index d7a0d1a1c9a..5aae09e6156 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -1232,9 +1232,12 @@ client_set_remote_options(char *value, xlator_t *this) char *remote_port_str = NULL; char *tmp = NULL; int remote_port = 0; - int ret = 0; + int ret = -1; dup_value = gf_strdup(value); + if (dup_value == NULL) { + goto out; + } host = strtok_r(dup_value, ":", &tmp); subvol = strtok_r(NULL, ":", &tmp); remote_port_str = strtok_r(NULL, ":", &tmp); @@ -1248,6 +1251,7 @@ client_set_remote_options(char *value, xlator_t *this) if (ret) { gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, "failed to set remote-host with %s", host); + GF_FREE(host_dup); goto out; } } @@ -1262,6 +1266,7 @@ client_set_remote_options(char *value, xlator_t *this) if (ret) { gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, "failed to set remote-host with %s", host); + GF_FREE(subvol_dup); goto out; } } -- cgit