summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Jinyu <xijinyu@cmss.chinamobile.com>2019-11-12 01:37:40 -0500
committerAmar Tumballi <amarts@gmail.com>2019-11-12 14:08:56 +0000
commit256c5dd228af503ece1aebe1229feac61b55f1d3 (patch)
tree76e706eb5333374a36ebe5b5e72dc220636abcdc
parent9f2ad630c877b7b3fb833c89ad85dc10bcf552c4 (diff)
libglusterfs/dict.c: Fix memory leaks.
fixes: bz#1771365 Change-Id: Id31687c4704cbbfea1084f912ed0420c7d1cc1ec Signed-off-by: Xi Jinyu <xijinyu@cmss.chinamobile.com>
-rw-r--r--libglusterfs/src/dict.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 1a873ed..e2fce75 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -804,6 +804,7 @@ int_to_data(int64_t value)
data->len = gf_asprintf(&data->data, "%" PRId64, value);
if (-1 == data->len) {
gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
data->len++; /* account for terminating NULL */
@@ -823,6 +824,7 @@ data_from_int64(int64_t value)
data->len = gf_asprintf(&data->data, "%" PRId64, value);
if (-1 == data->len) {
gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
data->len++; /* account for terminating NULL */
@@ -842,6 +844,7 @@ data_from_int32(int32_t value)
data->len = gf_asprintf(&data->data, "%" PRId32, value);
if (-1 == data->len) {
gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
@@ -862,6 +865,7 @@ data_from_int16(int16_t value)
data->len = gf_asprintf(&data->data, "%" PRId16, value);
if (-1 == data->len) {
gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
@@ -882,6 +886,7 @@ data_from_int8(int8_t value)
data->len = gf_asprintf(&data->data, "%d", value);
if (-1 == data->len) {
gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
@@ -902,6 +907,7 @@ data_from_uint64(uint64_t value)
data->len = gf_asprintf(&data->data, "%" PRIu64, value);
if (-1 == data->len) {
gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
@@ -922,6 +928,8 @@ data_from_double(double value)
data->len = gf_asprintf(&data->data, "%f", value);
if (data->len == -1) {
+ gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
data->len++; /* account for terminating NULL */
@@ -941,6 +949,7 @@ data_from_uint32(uint32_t value)
data->len = gf_asprintf(&data->data, "%" PRIu32, value);
if (-1 == data->len) {
gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}
@@ -960,6 +969,8 @@ data_from_uint16(uint16_t value)
}
data->len = gf_asprintf(&data->data, "%" PRIu16, value);
if (-1 == data->len) {
+ gf_msg_debug("dict", 0, "asprintf failed");
+ data_destroy(data);
return NULL;
}