public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/109570] New: detect fclose on unopened or NULL files
@ 2023-04-20 13:33 vanyacpp at gmail dot com
  2023-04-20 13:36 ` [Bug analyzer/109570] " vanyacpp at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vanyacpp at gmail dot com @ 2023-04-20 13:33 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-15 21:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 13:33 [Bug analyzer/109570] New: detect fclose on unopened or NULL files vanyacpp at gmail dot com
2023-04-20 13:36 ` [Bug analyzer/109570] " vanyacpp at gmail dot com
2023-04-20 21:31 ` dmalcolm at gcc dot gnu.org
2023-05-16 10:20 ` xry111 at gcc dot gnu.org
2023-05-16 20:29 ` clyon at gcc dot gnu.org
2023-05-17 15:03 ` clyon at gcc dot gnu.org
2023-05-17 15:14 ` xry111 at gcc dot gnu.org
2023-08-15 21:00 ` glebfm at altlinux dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).