Files
codeql/cpp/ql/src/Critical/FileMayNotBeClosed.cpp
2018-08-02 17:53:23 +01:00

10 lines
256 B
C++

FILE* f() {
try {
FILE *fp = fopen("foo.txt", "w");
do_stuff(fp);
return fp; //if there are no exceptions, the file pointer is returned correctly
} catch (int do_stuff_exception) {
return NULL; //returns NULL on error, but does not close fp
}
}