From: Danny Al-Gaaf Date: Thu, 26 Jun 2014 00:46:30 +0000 (+0200) Subject: scratchtool.c: fix resource leak X-Git-Tag: v0.83~32^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bdb134607dd11cf112db9caf8dbbdf486a3457e4;p=ceph.git 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 --- diff --git a/src/tools/scratchtool.c b/src/tools/scratchtool.c index eecafb4e3058..22c6a9fb16ba 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)