facebook / facebook/infer

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

Aperta
#1,419 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
c false-positive
Lingua principale
OCaml
Stelle
15.7k
Fork
2.1k
Merge medio
19h 36m
PR unite (30g)
13

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.