summaryrefslogtreecommitdiff
path: root/source4/torture/libsmbclient
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-08-23 14:00:29 +0200
committerJeremy Allison <jra@samba.org>2018-08-29 18:33:19 +0200
commit81f4971fc9a0cd597fcfaf5285170447a6482808 (patch)
treee789a4d57381a3ab08c3907887ef9cece3e31fa3 /source4/torture/libsmbclient
parent825d67fd35a809e779b916a82e63df8c8de01772 (diff)
downloadsamba-81f4971fc9a0cd597fcfaf5285170447a6482808.tar.gz
s4:torture: Improve torture_libsmbclient_init_context()
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source4/torture/libsmbclient')
-rw-r--r--source4/torture/libsmbclient/libsmbclient.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c
index e84ce018a69..b8fab225d90 100644
--- a/source4/torture/libsmbclient/libsmbclient.c
+++ b/source4/torture/libsmbclient/libsmbclient.c
@@ -43,11 +43,23 @@ static void debug_callback(void *private_ptr, int level, const char *msg)
bool torture_libsmbclient_init_context(struct torture_context *tctx,
SMBCCTX **ctx_p)
{
- SMBCCTX *ctx;
+ SMBCCTX *ctx = NULL;
+ SMBCCTX *p = NULL;
+ bool ok = true;
ctx = smbc_new_context();
- torture_assert(tctx, ctx, "failed to get new context");
- torture_assert(tctx, smbc_init_context(ctx), "failed to init context");
+ torture_assert_not_null_goto(tctx,
+ ctx,
+ ok,
+ out,
+ "Failed to create new context");
+
+ p = smbc_init_context(ctx);
+ torture_assert_not_null_goto(tctx,
+ p,
+ ok,
+ out,
+ "Failed to initialize context");
smbc_setDebug(ctx, DEBUGLEVEL);
smbc_setOptionDebugToStderr(ctx, 1);
@@ -57,7 +69,12 @@ bool torture_libsmbclient_init_context(struct torture_context *tctx,
*ctx_p = ctx;
- return true;
+out:
+ if (!ok) {
+ smbc_free_context(ctx, 1);
+ }
+
+ return ok;
}
static bool torture_libsmbclient_version(struct torture_context *tctx)