public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/99042] New: file-leak is wrong
@ 2021-02-09 18:54 antonio.chirizzi at gmail dot com
  2021-02-09 21:50 ` [Bug analyzer/99042] Another false -Wanalyzer-malloc-leak on code path involving unknown function call dmalcolm at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: antonio.chirizzi at gmail dot com @ 2021-02-09 18:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99042

            Bug ID: 99042
           Summary: file-leak is wrong
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: antonio.chirizzi at gmail dot com
  Target Milestone: ---

Created attachment 50155
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50155&action=edit
Reproducer log.c file for the bug

A file leak warning is shown, but it should not. See attached log.c reproducer.
Please note that I tried to strip the file to a minimum (while trying to leave
all the big complex data structures), but it still shows many warnings due to
undeclared functions (it's part of the git code base)
The leak warning is anyway consistent with what is shown on the real log.c file
in the code base.

In function ‘open_next_file’:
log.c:495:16: warning: leak of FILE ‘<unknown>’ [CWE-775]
[-Wanalyzer-file-leak]
  495 |         return 0;
      |                ^
  ‘open_next_file’: events 1-3
    |
    |  491 |         if ((rev->diffopt.file = fopen(filename.buf, "w")) ==
NULL)
    |      |            ^
    |      |            |
    |      |            (1) following ‘false’ branch...
    |......
    |  494 |         strbuf_release(&filename);
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |         |
    |      |         (2) ...to here
    |  495 |         return 0;
    |      |                ~
    |      |                |
    |      |                (3) ‘<unknown>’ leaks here
    |

Use "gcc -fanalyzer -c log.c"

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

end of thread, other threads:[~2021-04-08 13:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 18:54 [Bug analyzer/99042] New: file-leak is wrong antonio.chirizzi at gmail dot com
2021-02-09 21:50 ` [Bug analyzer/99042] Another false -Wanalyzer-malloc-leak on code path involving unknown function call dmalcolm at gcc dot gnu.org
2021-02-10  8:55 ` antonio.chirizzi at gmail dot com
2021-02-10 11:24 ` dmalcolm at gcc dot gnu.org
2021-04-08 13:47 ` cvs-commit at gcc dot gnu.org
2021-04-08 13:56 ` dmalcolm at gcc dot gnu.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).