summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhiqiang Liu <liuzhiqiang26@huawei.com>2020-11-05 18:26:18 +0800
committerNikolaus Rath <Nikolaus@rath.org>2020-11-06 19:26:03 +0000
commit71f0d7c366ee2ac2d6158c7c7ea6c3c2240ebc65 (patch)
tree59a29acf25d4146a51351964201b10d2bd31dc3b
parent8b4c5d90ee3137472fd63eea1b46cf19da874abd (diff)
downloadfuse-71f0d7c366ee2ac2d6158c7c7ea6c3c2240ebc65.tar.gz
test/test_syscalls.c: fix potential fd leakage problems
In test_syscalls.c, several funcs have potential fd leakage problems. This patch will fix them. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Haotian Li <lihaotian9@huawei.com>
-rw-r--r--test/test_syscalls.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/test_syscalls.c b/test/test_syscalls.c
index 18326c0..4fa5c87 100644
--- a/test/test_syscalls.c
+++ b/test/test_syscalls.c
@@ -779,6 +779,7 @@ static int test_copy_file_range(void)
res = close(fd_in);
if (res == -1) {
PERROR("close");
+ close(fd_out);
return -1;
}
res = close(fd_out);
@@ -932,8 +933,10 @@ static int test_create_unlink(void)
return -1;
}
res = check_nonexist(testfile);
- if (res == -1)
+ if (res == -1) {
+ close(fd);
return -1;
+ }
res = write(fd, data, datalen);
if (res == -1) {
PERROR("write");
@@ -1766,8 +1769,10 @@ static int test_socket(void)
}
res = check_type(testsock, S_IFSOCK);
- if (res == -1)
+ if (res == -1) {
+ close(fd);
return -1;
+ }
err += check_nlink(testsock, 1);
close(fd);
res = unlink(testsock);