]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/util: Fix CID 1414760 - Resource leak
authorShweta Sodani <ssodani@redhat.com>
Mon, 22 Sep 2025 09:06:58 +0000 (14:36 +0530)
committerAnoop C S <anoopcs@samba.org>
Sun, 28 Sep 2025 09:30:56 +0000 (09:30 +0000)
If read is failed torture_assert could return without freeing the t.
Fixing the leak.

Signed-off-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Sun Sep 28 09:30:56 UTC 2025 on atb-devel-224

lib/util/tests/tfork.c

index 599ed7e4b528bd94e5a30afb47b3979c941f1f01..19237a5156f8f9b2f615796665dc0091df1e9d7e 100644 (file)
@@ -403,7 +403,7 @@ static bool test_tfork_twice(struct torture_context *tctx)
        close(up[1]);
 
        ret = read(up[0], &pid, sizeof(pid_t));
-       torture_assert(tctx, ret == sizeof(pid_t), "read failed\n");
+       torture_assert_goto(tctx, ret == sizeof(pid_t), ok, done, "read failed\n");
 
        status = tfork_status(&t, true);
        torture_assert_goto(tctx, status != -1, ok, done, "tfork_status failed\n");
@@ -413,6 +413,10 @@ static bool test_tfork_twice(struct torture_context *tctx)
        torture_assert_goto(tctx, WEXITSTATUS(status) == 0, ok, done,
                            "tfork failed\n");
 done:
+       if (t != NULL) {
+               kill(child, SIGKILL);
+               free(t);
+       }
        return ok;
 }