False Positive Resource Leak with fdopendir(3) [C]
- 主要语言
- OCaml
- 星标
- 15.7k
- 派生
- 2.1k
- 平均合并
- 19 小时 36 分钟
- 30 天内合并 PR
- 13
描述
Version: pre-compiled 1.1.0 (https://github.com/facebook/infer/releases/download/v1.1.0/infer-linux64-v1.1.0.tar.xz)
```
Infer version v1.1.0
Copyright 2009 - present Facebook. All Rights Reserved.
```
OS: Debian sid
Example:
```c
#include
#include
#include
#include
#include
int foo(void) {
int fd = open("mydir", O_RDONLY);
if (fd < 0)
return -1;
DIR *d = fdopendir(fd);
if (!d) {
close(fd);
return -1;
}
closedir(d);
return 0;
}
```
Result:
```
infer run -- gcc -c test3.c
Capturing in make/cc mode...
Found 1 source file to analyze in infer-out
1/1 [################################################################################] 100% 45.118ms
test3.c:19: error: Resource Leak
resource acquired by call to `open()` at line 9, column 14 is not released after line 19, column 14.
17. }
18.
19. closedir(d);
^
20.
21. return 0;
Found 1 issue
Issue Type(ISSUED_TYPE_ID): #
Resource Leak(RESOURCE_LEAK): 1
```
man:fopendir(3) states:
After a successful call to fdopendir(), fd is used internally by the implementation, and should not otherwise be used by the application.
贡献指南
评估
这个 Issue 还没有评估数据。