diff options
author | Andreas Schneider <asn@samba.org> | 2016-06-22 08:01:05 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-06-24 02:01:19 +0200 |
commit | 4961362106152a1a0839a690cafe8824ea728745 (patch) | |
tree | a6f7e4fc54253ffd5c6dd086a11b64c4a3a78a5f /nsswitch | |
parent | 2ae40865bef6fd4fcf0584e0bd744914ec18a9ca (diff) | |
download | samba-4961362106152a1a0839a690cafe8824ea728745.tar.gz |
nsswitch: Fix memory leak in test_wbc_get_sidaliases()
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 | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c index 0ec5a069072..3bedf960331 100644 --- a/nsswitch/libwbclient/tests/wbclient.c +++ b/nsswitch/libwbclient/tests/wbclient.c @@ -514,36 +514,44 @@ fail: static bool test_wbc_get_sidaliases(struct torture_context *tctx) { struct wbcDomainSid builtin; - struct wbcDomainInfo *info; - struct wbcInterfaceDetails *details; + struct wbcDomainInfo *info = NULL; + struct wbcInterfaceDetails *details = NULL; struct wbcDomainSid sids[2]; - uint32_t *rids; + uint32_t *rids = NULL; uint32_t num_rids; - wbcErr ret; + wbcErr ret = false; - torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), - "%s", "wbcInterfaceDetails failed"); - torture_assert_wbc_ok( - tctx, wbcDomainInfo(details->netbios_domain, &info), - "wbcDomainInfo of %s failed", details->netbios_domain); - 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), + "wbcDomainInfo of %s failed", + details->netbios_domain); sids[0] = info->sid; sids[0].sub_auths[sids[0].num_auths++] = 500; sids[1] = info->sid; sids[1].sub_auths[sids[1].num_auths++] = 512; - wbcFreeMemory(info); - torture_assert_wbc_ok( - tctx, wbcStringToSid("S-1-5-32", &builtin), - "wbcStringToSid of %s failed", "S-1-5-32"); + torture_assert_wbc_ok_goto_fail(tctx, + wbcStringToSid("S-1-5-32", &builtin), + "wbcStringToSid of %s failed", + "S-1-5-32"); ret = wbcGetSidAliases(&builtin, sids, 2, &rids, &num_rids); - torture_assert_wbc_ok(tctx, ret, "%s", "wbcGetSidAliases failed"); + torture_assert_wbc_ok_goto_fail(tctx, + ret, + "%s", + "wbcGetSidAliases failed"); + ret = true; +fail: + wbcFreeMemory(details); + wbcFreeMemory(info); wbcFreeMemory(rids); - - return true; + return ret; } static bool test_wbc_authenticate_user_int(struct torture_context *tctx, |