From 093639d8003695889923cc7a106519c1f9a4e2f0 Mon Sep 17 00:00:00 2001 From: arao Date: Wed, 1 Apr 2015 12:29:24 +0530 Subject: cli: Fixing dereference after null check and dead code removal CID: 1124609 CID: 1124596 CID: 1124471 CID: 1124475 CID: 1124476 The pointer variables are checked before dereferencing and the dead code is removed BUG: 789278 Change-Id: Ia532733a64401d71ccf1f2b6e434d7bc910e0ed1 Signed-off-by: arao Reviewed-on: http://review.gluster.org/10083 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-rpc-ops.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 3065f64f0eb..6bfe78e4354 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -508,14 +508,13 @@ cli_out_options ( char *substr, char *optstr, char *valstr) while (ptr1) { + /* Avoiding segmentation fault. */ + if (!ptr2) + return; if (*ptr1 != *ptr2) break; ptr1++; ptr2++; - if (!ptr1) - return; - if (!ptr2) - return; } if (*ptr2 == '\0') @@ -1094,8 +1093,6 @@ out: cli_local_wipe (local); if (rsp.dict.dict_val) free (rsp.dict.dict_val); - if (dict) - dict_unref (dict); gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); return ret; @@ -1190,7 +1187,7 @@ gf_cli_start_volume_cbk (struct rpc_req *req, struct iovec *iov, ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (frame->this->name, GF_LOG_ERROR, "dict get failed"); + gf_log ("cli", GF_LOG_ERROR, "dict get failed"); goto out; } @@ -1614,7 +1611,7 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, ret = dict_get_int32 (local_dict, "rebalance-command", (int32_t*)&cmd); if (ret) { - gf_log (frame->this->name, GF_LOG_ERROR, + gf_log ("cli", GF_LOG_ERROR, "Failed to get command"); goto out; } -- cgit