diff options
author | Andreas Schneider <asn@samba.org> | 2016-06-22 08:16:11 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-06-24 02:01:19 +0200 |
commit | 6a620adb25ada71470ab890a3734c0007de55921 (patch) | |
tree | 48e03d19a236ef1803c50cd37a2e25680619e0b5 /nsswitch | |
parent | 9b732c2448a166fdbfc43d1dda23ba7164a79db4 (diff) | |
download | samba-6a620adb25ada71470ab890a3734c0007de55921.tar.gz |
nsswitch: Fix memory leak in test_wbc_domain_info()
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.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c index 380a3dd02c2..41a581e488b 100644 --- a/nsswitch/libwbclient/tests/wbclient.c +++ b/nsswitch/libwbclient/tests/wbclient.c @@ -255,21 +255,31 @@ static bool test_wbc_guidtostring(struct torture_context *tctx) static bool test_wbc_domain_info(struct torture_context *tctx) { - struct wbcDomainInfo *info; - struct wbcInterfaceDetails *details; + struct wbcDomainInfo *info = NULL; + struct wbcInterfaceDetails *details = NULL; + wbcErr ret = false; - torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), - "%s", "wbcInterfaceDetails failed"); - torture_assert_wbc_ok( - tctx, wbcDomainInfo(details->netbios_domain, &info), - "%s", "wbcDomainInfo failed"); - wbcFreeMemory(details); + torture_assert_wbc_ok_goto_fail(tctx, + wbcInterfaceDetails(&details), + "%s", + "wbcInterfaceDetails failed"); + torture_assert_wbc_ok_goto_fail(tctx, + wbcDomainInfo(details->netbios_domain, &info), + "%s", + "wbcDomainInfo failed"); + + torture_assert_goto(tctx, + info, + ret, + fail, + "wbcDomainInfo returned NULL pointer"); - torture_assert(tctx, info, - "wbcDomainInfo returned NULL pointer"); + ret = true; +fail: + wbcFreeMemory(details); wbcFreeMemory(info); - return true; + return ret; } static bool test_wbc_users(struct torture_context *tctx) |