public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/99044] New: use-after-free false positive
@ 2021-02-09 19:41 antonio.chirizzi at gmail dot com
  2021-02-09 22:15 ` [Bug analyzer/99044] use-after-free false positive in loop dmalcolm at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: antonio.chirizzi at gmail dot com @ 2021-02-09 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99044
           Summary: use-after-free false positive
           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 50157
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50157&action=edit
Reproducer for the bug

Please find attached the reproducer for this use-after-free which looks a false
positive.

ls-tree-with-commit.c: In function ‘oid2strbuf_free’:
ls-tree-with-commit.c:53:17: warning: use after ‘free’ of ‘e_strbuf’ [CWE-416]
[-Wanalyzer-use-after-free]
   53 |                 strbuf_release(e_strbuf->value);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ‘oid2strbuf_free’: events 1-6
    |
    |   51 |         while ((e = hashmap_iter_next(&iter))) {
    |      |                ^
    |      |                |
    |      |                (1) following ‘true’ branch (when ‘e’ is
non-NULL)...
    |      |                (4) following ‘true’ branch (when ‘e’ is
non-NULL)...
    |   52 |                 struct oid2strbuf *e_strbuf = (struct oid2strbuf
*)e;
    |      |                                    ~~~~~~~~
    |      |                                    |
    |      |                                    (2) ...to here
    |      |                                    (5) ...to here
    |   53 |                 strbuf_release(e_strbuf->value);
    |      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                 |
    |      |                 (6) use after ‘free’ of ‘e_strbuf’; freed at (3)
    |   54 |                 free(e_strbuf->value);
    |   55 |                 free(e);
    |      |                 ~~~~~~~
    |      |                 |
    |      |                 (3) freed here



use "gcc -fanalyzer -c ls-tree-with-commit.c"

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

end of thread, other threads:[~2021-03-25  0:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 19:41 [Bug analyzer/99044] New: use-after-free false positive antonio.chirizzi at gmail dot com
2021-02-09 22:15 ` [Bug analyzer/99044] use-after-free false positive in loop dmalcolm at gcc dot gnu.org
2021-03-25  0:48 ` cvs-commit at gcc dot gnu.org
2021-03-25  0:55 ` 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).