summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2016-06-22 08:53:51 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-06-24 02:01:19 +0200
commit539116e5884131d73af8ad3e7ec04010477ccc22 (patch)
tree5b1e78dccb28651805f9901f13c125bb45307630 /nsswitch
parent3c9f0815fb0822c7e9521b5526c24addd9f89a34 (diff)
downloadsamba-539116e5884131d73af8ad3e7ec04010477ccc22.tar.gz
nsswitch: Fix memory leak in test_wbc_trusts()
Found by cppcheck. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/libwbclient/tests/wbclient.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index 94a932f8526..0412bed0f22 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -466,26 +466,35 @@ fail:
static bool test_wbc_trusts(struct torture_context *tctx)
{
- struct wbcDomainInfo *domains;
+ struct wbcDomainInfo *domains = NULL;
+ struct wbcAuthErrorInfo *error = NULL;
size_t num_domains;
- int i;
+ uint32_t i;
+ wbcErr ret = false;
- torture_assert_wbc_ok(tctx, wbcListTrusts(&domains, &num_domains),
- "%s", "wbcListTrusts failed");
- torture_assert(tctx, !(num_domains > 0 && !domains),
- "wbcListTrusts returned invalid results");
+ torture_assert_wbc_ok_goto_fail(tctx,
+ wbcListTrusts(&domains, &num_domains),
+ "%s",
+ "wbcListTrusts failed");
+ torture_assert_goto(tctx,
+ !(num_domains > 0 && !domains),
+ ret,
+ fail,
+ "wbcListTrusts returned invalid results");
for (i=0; i < MIN(num_domains,100); i++) {
- struct wbcAuthErrorInfo *error;
/*
struct wbcDomainSid sid;
enum wbcSidType name_type;
char *domain;
char *name;
*/
- torture_assert_wbc_ok(tctx, wbcCheckTrustCredentials(domains[i].short_name, &error),
- "%s", "wbcCheckTrustCredentials failed");
+ torture_assert_wbc_ok_goto_fail(tctx,
+ wbcCheckTrustCredentials(domains[i].short_name,
+ &error),
+ "%s",
+ "wbcCheckTrustCredentials failed");
/*
torture_assert_wbc_ok(tctx, wbcLookupName(domains[i].short_name, NULL, &sid, &name_type),
"wbcLookupName failed");
@@ -498,10 +507,16 @@ static bool test_wbc_trusts(struct torture_context *tctx)
torture_assert(tctx, name,
"wbcLookupSid returned no name");
*/
+ wbcFreeMemory(error);
+ error = NULL;
}
+
+ ret = true;
+fail:
wbcFreeMemory(domains);
+ wbcFreeMemory(error);
- return true;
+ return ret;
}
static bool test_wbc_lookupdc(struct torture_context *tctx)