summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/dict.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-03-21 08:35:12 +0530
committerAnand Avati <avati@redhat.com>2014-04-28 18:00:44 -0700
commit3ea85192f1521c32915ed38bb4db61be11d59922 (patch)
tree6dd6c85bddc6447dd6da03df24a8b6312ee904e9 /libglusterfs/src/dict.c
parentc52ab5eb52519d41b0ae146ec7b1276f2ffae9e9 (diff)
dict: de-allocate data on dict-set failures
Found the bug while browsing code. Very difficult to hit this though. Change-Id: I84bd5d23d19b6aa16866fc0f1b56aa22cb8a5f1f BUG: 1079215 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/7310 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/dict.c')
-rw-r--r--libglusterfs/src/dict.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 1198c65b1d4..b5ebe6cea3d 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -1602,6 +1602,8 @@ dict_set_int8 (dict_t *this, char *key, int8_t val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1645,6 +1647,8 @@ dict_set_int16 (dict_t *this, char *key, int16_t val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1688,6 +1692,8 @@ dict_set_int32 (dict_t *this, char *key, int32_t val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1731,6 +1737,8 @@ dict_set_int64 (dict_t *this, char *key, int64_t val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1774,6 +1782,8 @@ dict_set_uint16 (dict_t *this, char *key, uint16_t val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1818,6 +1828,8 @@ dict_set_uint32 (dict_t *this, char *key, uint32_t val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1861,6 +1873,8 @@ dict_set_uint64 (dict_t *this, char *key, uint64_t val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1903,6 +1917,8 @@ dict_set_double (dict_t *this, char *key, double val)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1921,6 +1937,8 @@ dict_set_static_ptr (dict_t *this, char *key, void *ptr)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -1939,6 +1957,8 @@ dict_set_dynptr (dict_t *this, char *key, void *ptr, size_t len)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -2015,6 +2035,8 @@ dict_set_ptr (dict_t *this, char *key, void *ptr)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -2061,6 +2083,8 @@ dict_set_str (dict_t *this, char *key, char *str)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -2096,6 +2120,8 @@ dict_set_dynstr (dict_t *this, char *key, char *str)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -2117,6 +2143,8 @@ dict_set_dynmstr (dict_t *this, char *key, char *str)
}
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -2173,6 +2201,8 @@ dict_set_bin (dict_t *this, char *key, void *ptr, size_t size)
data->is_static = 0;
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;
@@ -2201,6 +2231,8 @@ dict_set_static_bin (dict_t *this, char *key, void *ptr, size_t size)
data->is_static = 1;
ret = dict_set (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
err:
return ret;