summaryrefslogtreecommitdiffstats
path: root/src/tools/scratchtool.c
diff options
context:
space:
mode:
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>2014-06-26 02:46:30 +0200
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>2014-06-26 02:50:29 +0200
commitbdb134607dd11cf112db9caf8dbbdf486a3457e4 (patch)
treeacd47e601549616ac78dc1e57abe4ffb7a3789a7 /src/tools/scratchtool.c
parentlibcephfs/test.cc: fix use after free (diff)
downloadceph-bdb134607dd11cf112db9caf8dbbdf486a3457e4.tar.xz
ceph-bdb134607dd11cf112db9caf8dbbdf486a3457e4.zip
scratchtool.c: fix resource leak
CID 1219612 (#1 - 3): Resource leak (RESOURCE_LEAK) leaked_storage: Variable iter going out of scope leaks the storage it points to. Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Diffstat (limited to 'src/tools/scratchtool.c')
-rw-r--r--src/tools/scratchtool.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/tools/scratchtool.c b/src/tools/scratchtool.c
index eecafb4e305..22c6a9fb16b 100644
--- a/src/tools/scratchtool.c
+++ b/src/tools/scratchtool.c
@@ -73,7 +73,7 @@ static int do_rados_getxattrs(rados_ioctx_t io_ctx, const char *oid,
if (ret) {
printf("rados_getxattrs(%s): rados_getxattrs_next "
"returned error %d\n", oid, ret);
- return 1;
+ goto out_err;
}
if (!key)
break;
@@ -87,17 +87,21 @@ static int do_rados_getxattrs(rados_ioctx_t io_ctx, const char *oid,
printf("rados_getxattrs(%s): got key %s, but the "
"value was %s rather than %s.\n",
oid, key, val, exvals[i]);
- return 1;
+ goto out_err;
}
}
if (nfound != nval) {
printf("rados_getxattrs(%s): only found %d extended attributes. "
"Expected %d\n", oid, nfound, nval);
- return 1;
+ goto out_err;
}
rados_getxattrs_end(iter);
printf("rados_getxattrs(%s)\n", oid);
return 0;
+
+out_err:
+ rados_getxattrs_end(iter);
+ return 1;
}
static int testrados(void)