facebook / facebook/infer

False Positive Resource Leak with fdopendir(3) [C]

オープン
#1,419 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
c false-positive
主要言語
OCaml
スター
15.7k
フォーク
2.1k
平均マージ
19時間 36分
マージ済み PR(30日)
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。