diff options
author | Andreas Schneider <asn@samba.org> | 2016-06-22 07:56:20 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-06-24 02:01:19 +0200 |
commit | 2ae40865bef6fd4fcf0584e0bd744914ec18a9ca (patch) | |
tree | 761053e3faeebf1d15b47b1a5c0652e80d81020f /nsswitch/libwbclient | |
parent | f479a1f896d1582d41ac45ebdc003d438198fcda (diff) | |
download | samba-2ae40865bef6fd4fcf0584e0bd744914ec18a9ca.tar.gz |
nsswitch: Fix memory leak in test_wbc_pingdc()
Found by cppcheck.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
Diffstat (limited to 'nsswitch/libwbclient')
-rw-r--r-- | nsswitch/libwbclient/tests/wbclient.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c index a8acf078d3d..0ec5a069072 100644 --- a/nsswitch/libwbclient/tests/wbclient.c +++ b/nsswitch/libwbclient/tests/wbclient.c @@ -79,28 +79,38 @@ static bool test_wbc_ping(struct torture_context *tctx) static bool test_wbc_pingdc(struct torture_context *tctx) { - struct wbcInterfaceDetails *details; + struct wbcInterfaceDetails *details = NULL; + wbcErr ret = false; - torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_DOMAIN_NOT_FOUND, - "%s", "wbcPingDc failed"); - torture_assert_wbc_ok(tctx, wbcPingDc(NULL, NULL), + torture_assert_wbc_equal_goto_fail(tctx, + wbcPingDc("random_string", NULL), + WBC_ERR_DOMAIN_NOT_FOUND, + "%s", + "wbcPingDc failed"); + torture_assert_wbc_ok_goto_fail(tctx, wbcPingDc(NULL, NULL), "%s", "wbcPingDc failed"); - torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), + torture_assert_wbc_ok_goto_fail(tctx, wbcInterfaceDetails(&details), "%s", "wbcInterfaceDetails failed"); - torture_assert(tctx, details, + torture_assert_goto(tctx, details, ret, fail, "wbcInterfaceDetails returned NULL pointer"); - torture_assert(tctx, details->netbios_domain, + torture_assert_goto(tctx, details->netbios_domain, ret, fail, "wbcInterfaceDetails returned NULL netbios_domain"); - torture_assert_wbc_ok(tctx, wbcPingDc(details->netbios_domain, NULL), - "wbcPingDc(%s) failed", details->netbios_domain); + torture_assert_wbc_ok_goto_fail(tctx, + wbcPingDc(details->netbios_domain, NULL), + "wbcPingDc(%s) failed", + details->netbios_domain); - torture_assert_wbc_ok(tctx, wbcPingDc("BUILTIN", NULL), - "%s", "wbcPingDc(BUILTIN) failed"); + torture_assert_wbc_ok_goto_fail(tctx, + wbcPingDc("BUILTIN", NULL), + "%s", + "wbcPingDc(BUILTIN) failed"); + ret = true; +fail: wbcFreeMemory(details); - return true; + return ret; } static bool test_wbc_pingdc2(struct torture_context *tctx) |