torture:smb2: fix crashes in smb2.durable-open.reopen1a test
authorMichael Adam <obnox@samba.org>
Fri, 4 Mar 2016 21:55:40 +0000 (22:55 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 21 Mar 2016 23:23:21 +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_open.c

index 11388ef3828e45397652bca60b664cf79bc01ed7..e8a82c0b3a4ebfda6a80728cb73668cb04ee0ed5 100644 (file)
@@ -479,6 +479,8 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx,
        status = smb2_create(tree, mem_ctx, &io2);
        CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED);
 
+       TALLOC_FREE(tree);
+
        /*
         * but a durable reconnect on the new session succeeds:
         */
@@ -495,15 +497,19 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx,
        h = &_h;
 
 done:
-       if (h != NULL) {
-               smb2_util_close(tree2, *h);
+       if (tree == NULL) {
+               tree = tree2;
        }
 
-       smb2_util_unlink(tree2, fname);
-
-       talloc_free(tree2);
+       if (tree != NULL) {
+               if (h != NULL) {
+                       smb2_util_close(tree, *h);
+                       h = NULL;
+               }
+               smb2_util_unlink(tree, fname);
 
-       talloc_free(tree);
+               talloc_free(tree);
+       }
 
        talloc_free(mem_ctx);