Issue |
133942
|
Summary |
False-positive: fopen() without fclose() in main() reported as a "resource leak"
|
Labels |
|
Assignees |
|
Reporter |
alavrentiev
|
```
int main(int argc, char** argv)
{
int port;
FILE* fp;
/* Cmd.-line args */
if (argc != 4 ||
(fp = fopen(argv[1], "r")) == 0 ||
((port = atoi(argv[3])) & ~0xFFFF)) {
fputs("\nUSAGE:\n"
"test_fw <inp_file> <host> <port>\n\n", stderr);
return 1; // <== Opened stream never closed. Potential resource leak
}
...
/* some work is done here */
...
}
```
Return from `main()` with an open file does not pose any resource leaks, as the file gets closed by C RTL right away.
It if was any other function, then yes, in such a situation the report would be justified and true, but *not* for `main()`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs