diff options
author | Zhou Zhengping <johnzzpcrystal@gmail.com> | 2016-07-10 09:10:49 -0400 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2016-07-14 14:14:28 -0700 |
commit | ab56ec1e99cd76d45b52d841e6b0009f94a3268b (patch) | |
tree | 9b6170a831ddfd96fbed11c455ebb7f8d66a1e5f | |
parent | 8d3ef3322aa7fccff842e508a1bfd5be71e18849 (diff) | |
download | glusterfs-ab56ec1e99cd76d45b52d841e6b0009f94a3268b.tar.gz glusterfs-ab56ec1e99cd76d45b52d841e6b0009f94a3268b.tar.xz glusterfs-ab56ec1e99cd76d45b52d841e6b0009f94a3268b.zip |
rpc: fix several problems in failure handle logic
Once dynstr is set into a dict by function dict_set_dynstr, its free
operation will be called by this dict when the dict is destroyed.
Signed-off-by: Zhou Zhengping <johnzzpcrystal@gmail.com>
Change-Id: Idd2bd19a041bcb477e1c897428ca1740fb75c5f3
BUG: 1354141
Reviewed-on: http://review.gluster.org/14882
Tested-by: Zhou Zhengping <johnzzpcrystal@gmail.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
-rw-r--r-- | libglusterfs/src/dict.c | 2 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.c | 17 |
2 files changed, 8 insertions, 11 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index 25ddff0d8c..6f7adb5158 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -258,8 +258,6 @@ data_copy (data_t *old) return newdata; err_out: - - FREE (newdata->data); mem_put (newdata); return NULL; diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index e224dcc022..1216b9fb3d 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -617,8 +617,10 @@ rpc_transport_unix_options_build (dict_t **options, char *filepath, } ret = dict_set_dynstr (dict, "transport.socket.connect-path", fpath); - if (ret) + if (ret) { + GF_FREE (fpath); goto out; + } ret = dict_set_str (dict, "transport.address-family", "unix"); if (ret) @@ -644,10 +646,8 @@ rpc_transport_unix_options_build (dict_t **options, char *filepath, *options = dict; out: - if (ret) { - GF_FREE (fpath); - if (dict) - dict_unref (dict); + if (ret && dict) { + dict_unref (dict); } return ret; } @@ -676,6 +676,7 @@ rpc_transport_inet_options_build (dict_t **options, const char *hostname, ret = dict_set_dynstr (dict, "remote-host", host); if (ret) { + GF_FREE (host); gf_log (THIS->name, GF_LOG_WARNING, "failed to set remote-host with %s", host); goto out; @@ -697,10 +698,8 @@ rpc_transport_inet_options_build (dict_t **options, const char *hostname, *options = dict; out: - if (ret) { - GF_FREE (host); - if (dict) - dict_unref (dict); + if (ret && dict) { + dict_unref (dict); } return ret; |