summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/dict.c
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-03-24 14:01:36 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-03-31 09:43:29 -0700
commit41f05fcefc1c192a3f322e827114897ec0ace316 (patch)
treec5500aed5d5f993256a98341b2482fdefaf3c3c1 /libglusterfs/src/dict.c
parentaa6028a600ccfea14d3f047402dfe157047cabdc (diff)
Fix further cppcheck reported issues.
Reported-by: Patrick Matthäi <pmatthaei@debian.org> Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 420 (fix leaks pointed out by cppcheck static analyzer) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=420
Diffstat (limited to 'libglusterfs/src/dict.c')
-rw-r--r--libglusterfs/src/dict.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index b8728ac1306..9e97bf1d422 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -168,19 +168,32 @@ data_copy (data_t *old)
if (old) {
newdata->len = old->len;
- if (old->data)
+ if (old->data) {
newdata->data = memdup (old->data, old->len);
- if (old->vec)
+ if (!newdata->data)
+ goto err_out;
+ }
+ if (old->vec) {
newdata->vec = memdup (old->vec, old->len * (sizeof (void *) +
sizeof (size_t)));
- if (!old->data && !old->vec) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@newdata->data || @newdata->vec got NULL from CALLOC()");
- return NULL;
+ if (!newdata->vec)
+ goto err_out;
}
}
return newdata;
+
+ err_out:
+
+ if (newdata->data)
+ FREE (newdata->data);
+ if (newdata->vec)
+ FREE (newdata->vec);
+ FREE (newdata);
+
+ gf_log ("dict", GF_LOG_CRITICAL,
+ "@newdata->data || @newdata->vec got NULL from CALLOC()");
+ return NULL;
}
static data_pair_t *
@@ -248,6 +261,8 @@ _dict_set (dict_t *this,
if (!pair->key) {
gf_log ("dict", GF_LOG_CRITICAL,
"@pair->key - NULL returned by CALLOC");
+ FREE (pair);
+
return -1;
}