https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109570
Bug ID: 109570
Summary: detect fclose on unopened or NULL files
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: vanyacpp at gmail dot com
Target Milestone: ---
While cleaning up one not particularly well written program I noticed this code
fragment:
FILE* file = fopen(...);
if (!file)
{
fclose(file);
return false;
}
Passing NULL to fclose is undefined behavior. Perhaps -fanalyzer could warn
about code like this?