s4:torture/smb2: try to fix a RESOURCE_LEAK in smb2.samba3misc.localposixlock1
authorStefan Metzmacher <metze@samba.org>
Tue, 10 Sep 2019 10:37:52 +0000 (12:37 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 10 Sep 2019 18:56:45 +0000 (18:56 +0000)
CID 1453656:    (RESOURCE_LEAK)
Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Sep 10 18:56:45 UTC 2019 on sn-devel-184

source4/torture/smb2/samba3misc.c

index a5fe6c1bbeab1bad3ed45f4c813eaefeeb61f821..cf4d9bbe18f4d44d89fadf6a32c2b3c2668e1518 100644 (file)
@@ -127,7 +127,8 @@ static bool torture_samba3_localposixlock1(struct torture_context *tctx,
        rc = fcntl(fd, F_SETLK, &posix_lock);
        if (rc == -1) {
                torture_warning(tctx, "fcntl failed: %s\n", strerror(errno));
-               torture_assert(tctx, rc != -1, "fcntl lock\n");
+               torture_assert_goto(tctx, rc != -1, ret, done,
+                                   "fcntl lock\n");
        }
 
        el[0].offset            = 0;
@@ -147,13 +148,13 @@ static bool torture_samba3_localposixlock1(struct torture_context *tctx,
        torture_comment(tctx, "  remote async blocking lock\n");
        el[0].flags             = SMB2_LOCK_FLAG_EXCLUSIVE;
        req = smb2_lock_send(tree, &lck);
-       torture_assert(tctx, req != NULL, "smb2_lock_send()\n");
+       torture_assert_goto(tctx, req != NULL, ret, done, "smb2_lock_send()\n");
 
        te = tevent_add_timer(tctx->ev,
                              tctx, timeval_current_ofs(5, 0),
                              torture_smb2_tree_disconnect_timer,
                              tree);
-       torture_assert(tctx, te != NULL, "tevent_add_timer\n");
+       torture_assert_goto(tctx, te != NULL, ret, done, "tevent_add_timer\n");
 
        torture_comment(tctx, "  remote wait for STATUS_PENDING\n");
        WAIT_FOR_ASYNC_RESPONSE(req);