summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2016-06-22 08:04:53 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-06-24 02:01:19 +0200
commit9b732c2448a166fdbfc43d1dda23ba7164a79db4 (patch)
treeb63b353d900ad5ab4bea8e56706f47669e2b75f1 /nsswitch
parent4961362106152a1a0839a690cafe8824ea728745 (diff)
downloadsamba-9b732c2448a166fdbfc43d1dda23ba7164a79db4.tar.gz
nsswitch: Fix memory leak in test_wbc_pingdc2()
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.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index 3bedf960331..380a3dd02c2 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -115,35 +115,55 @@ fail:
static bool test_wbc_pingdc2(struct torture_context *tctx)
{
- struct wbcInterfaceDetails *details;
+ struct wbcInterfaceDetails *details = NULL;
char *name = NULL;
+ wbcErr ret = false;
- torture_assert_wbc_equal(tctx, wbcPingDc2("random_string", NULL, &name),
- WBC_ERR_DOMAIN_NOT_FOUND, "%s",
- "wbcPingDc2 failed");
- torture_assert_wbc_ok(tctx, wbcPingDc2(NULL, NULL, &name), "%s",
- "wbcPingDc2 failed");
-
+ torture_assert_wbc_equal_goto_fail(tctx,
+ wbcPingDc2("random_string", NULL, &name),
+ WBC_ERR_DOMAIN_NOT_FOUND,
+ "%s",
+ "wbcPingDc2 failed");
+ torture_assert_wbc_ok_goto_fail(tctx,
+ wbcPingDc2(NULL, NULL, &name),
+ "%s",
+ "wbcPingDc2 failed");
wbcFreeMemory(name);
+ name = NULL;
- torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
- "%s", "wbcInterfaceDetails failed");
- torture_assert(tctx, details,
- "wbcInterfaceDetails returned NULL pointer");
- torture_assert(tctx, details->netbios_domain,
- "wbcInterfaceDetails returned NULL netbios_domain");
+ torture_assert_wbc_ok_goto_fail(tctx,
+ wbcInterfaceDetails(&details),
+ "%s",
+ "wbcInterfaceDetails failed");
+ torture_assert_goto(tctx,
+ details,
+ ret,
+ fail,
+ "wbcInterfaceDetails returned NULL pointer");
+ torture_assert_goto(tctx,
+ details->netbios_domain,
+ ret,
+ fail,
+ "wbcInterfaceDetails returned NULL netbios_domain");
- torture_assert_wbc_ok(tctx, wbcPingDc2(details->netbios_domain, NULL, &name),
- "wbcPingDc2(%s) failed", details->netbios_domain);
+ torture_assert_wbc_ok_goto_fail(tctx,
+ wbcPingDc2(details->netbios_domain, NULL, &name),
+ "wbcPingDc2(%s) failed",
+ details->netbios_domain);
wbcFreeMemory(name);
+ name = NULL;
- torture_assert_wbc_ok(tctx, wbcPingDc2("BUILTIN", NULL, &name),
- "%s", "wbcPingDc2(BUILTIN) failed");
- wbcFreeMemory(name);
+ torture_assert_wbc_ok_goto_fail(tctx,
+ wbcPingDc2("BUILTIN", NULL, &name),
+ "%s",
+ "wbcPingDc2(BUILTIN) failed");
+ ret = true;
+fail:
+ wbcFreeMemory(name);
wbcFreeMemory(details);
- return true;
+ return ret;
}
static bool test_wbc_library_details(struct torture_context *tctx)