]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/util: Fix CID 1414760 - Memory leak
authorShweta Sodani <ssodani@redhat.com>
Mon, 4 Aug 2025 11:39:23 +0000 (17:09 +0530)
committerAnoop C S <anoopcs@samba.org>
Tue, 12 Aug 2025 09:32:18 +0000 (09:32 +0000)
local variable 't' is reusing in child process, resulting the leaking
the tfork object as a side effect.

This fixes coverity issue#1414760

Signed-off-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: Shachar Sharon <ssharon@redhat.com>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Aug 12 09:32:19 UTC 2025 on atb-devel-224

lib/util/tests/tfork.c

index 70ae97583fca26fd384c3e1bd46c9915bf9cfdc8..599ed7e4b528bd94e5a30afb47b3979c941f1f01 100644 (file)
@@ -373,14 +373,16 @@ static bool test_tfork_twice(struct torture_context *tctx)
        }
        child = tfork_child_pid(t);
        if (child == 0) {
+               struct tfork *t1 = NULL;
+
                close(up[0]);
 
-               t = tfork_create();
-               if (t == NULL) {
+               t1 = tfork_create();
+               if (t1 == NULL) {
                        torture_fail(tctx, "tfork failed\n");
                        return false;
                }
-               child = tfork_child_pid(t);
+               child = tfork_child_pid(t1);
                if (child == 0) {
                        sleep(1);
                        pid = getpid();
@@ -393,6 +395,8 @@ static bool test_tfork_twice(struct torture_context *tctx)
                        _exit(1);
                }
 
+               status = tfork_status(&t1, true);
+               torture_assert_goto(tctx, status != -1, ok, done, "tfork_status failed\n");
                _exit(0);
        }