lib:replace: Fix possible resource leaks in test_closefrom()
[bbaumbach/samba-autobuild/.git] / 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");
                fd = dup(0);
                if (fd == -1) {
                        perror("dup failed");
+                       closefrom(3);
                        return false;
                }
 
                        return false;
                }
 
@@ -1096,6 +1097,7 @@ static bool test_closefrom(void)
 
                if (fd >= 1000) {
                        printf("fd=%d\n", fd);
 
                if (fd >= 1000) {
                        printf("fd=%d\n", fd);
+                       closefrom(3);
                        return false;
                }
        }
                        return false;
                }
        }