Skip to content

Commit

Permalink
nsswitch: Fix memory leak in test_wbc_domain_info()
Browse files Browse the repository at this point in the history
Found by cppcheck.

Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Uri Simchoni <[email protected]>
  • Loading branch information
cryptomilk committed Jun 24, 2016
1 parent 9b732c2 commit 6a620ad
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions nsswitch/libwbclient/tests/wbclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6a620ad

Please sign in to comment.