]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:replace: Fix possible resource leaks in test_closefrom()
authorAndreas Schneider <asn@samba.org>
Thu, 22 Apr 2021 13:25:57 +0000 (15:25 +0200)
committerJeremy Allison <jra@samba.org>
Sun, 25 Apr 2021 22:02:19 +0000 (22:02 +0000)
Found by covscan

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sun Apr 25 22:02:20 UTC 2021 on sn-devel-184

lib/replace/tests/testsuite.c

index c51a29740e91e484bfb92a1d225aa2b4e9dbcdcf..d8afa15480b031324cbd988f0fe708e487d6791e 100644 (file)
@@ -1089,6 +1089,7 @@ static bool test_closefrom(void)
                fd = dup(0);
                if (fd == -1) {
                        perror("dup failed");
+                       closefrom(3);
                        return false;
                }
 
@@ -1096,6 +1097,7 @@ static bool test_closefrom(void)
 
                if (fd >= 1000) {
                        printf("fd=%d\n", fd);
+                       closefrom(3);
                        return false;
                }
        }