torture:smb2: fix crashes in smb2.durable-v2-open.reopen1a test
authorMichael Adam <obnox@samba.org>
Tue, 15 Mar 2016 08:44:06 +0000 (09:44 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 21 Mar 2016 23:23:22 +0000 (00:23 +0100)
If the test failed too early, we dereferenced tree2 which
was still NULL.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/smb2/durable_v2_open.c

index a80506acbdcc611cc75a640412909d568b9440b0..de24c8f0dafe25aae5afb83f2258dec42e1f5a9b 100644 (file)
@@ -644,6 +644,8 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx,
        status = smb2_create(tree, mem_ctx, &io);
        CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED);
 
+       TALLOC_FREE(tree);
+
        /*
         * but a durable reconnect on the new session succeeds:
         */
@@ -664,13 +666,19 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx,
        h = &_h;
 
 done:
-       if (h != NULL) {
-               smb2_util_close(tree, *h);
+       if (tree == NULL) {
+               tree = tree2;
        }
 
-       smb2_util_unlink(tree, fname);
+       if (tree != NULL) {
+               if (h != NULL) {
+                       smb2_util_close(tree, *h);
+               }
 
-       talloc_free(tree);
+               smb2_util_unlink(tree, fname);
+
+               talloc_free(tree);
+       }
 
        talloc_free(mem_ctx);