summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/graph.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/graph.c')
-rw-r--r--libglusterfs/src/graph.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 2e290bb20a1..04bb92c7c75 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -598,16 +598,19 @@ _glusterfs_reachable_leaves(xlator_t *base, xlator_t *xl, dict_t *leaves)
xlator_list_t *list = NULL;
int err = 1;
int pos = 0;
- char strpos[6];
+ char *strpos = NULL;
if (glusterfs_is_leaf(xl)) {
pos = glusterfs_leaf_position(xl);
if (pos < 0)
goto out;
- sprintf(strpos, "%d", pos);
- err = dict_set_static_ptr(leaves, strpos, base);
+ err = gf_asprintf(&strpos, "%d", pos);
+ if (err >= 0) {
+ err = dict_set_static_ptr(leaves, strpos, base);
+ GF_FREE (strpos);
+ }
} else {
for (err = 0, list = xl->children;
!err && list;