Skip to content

Commit 634dc83

Browse files
Shweta Sodanianoopcs9
authored andcommitted
lib/util: Fix CID 1414760 - Memory leak
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
1 parent 82dd1ee commit 634dc83

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/util/tests/tfork.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,16 @@ static bool test_tfork_twice(struct torture_context *tctx)
373373
}
374374
child = tfork_child_pid(t);
375375
if (child == 0) {
376+
struct tfork *t1 = NULL;
377+
376378
close(up[0]);
377379

378-
t = tfork_create();
379-
if (t == NULL) {
380+
t1 = tfork_create();
381+
if (t1 == NULL) {
380382
torture_fail(tctx, "tfork failed\n");
381383
return false;
382384
}
383-
child = tfork_child_pid(t);
385+
child = tfork_child_pid(t1);
384386
if (child == 0) {
385387
sleep(1);
386388
pid = getpid();
@@ -393,6 +395,8 @@ static bool test_tfork_twice(struct torture_context *tctx)
393395
_exit(1);
394396
}
395397

398+
status = tfork_status(&t1, true);
399+
torture_assert_goto(tctx, status != -1, ok, done, "tfork_status failed\n");
396400
_exit(0);
397401
}
398402

0 commit comments

Comments
 (0)