public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/109120] New: False positive -Wanalyzer-malloc-leak with failed iconv_open()
@ 2023-03-14  5:37 urs at akk dot org
  2023-03-14 15:16 ` [Bug analyzer/109120] " dmalcolm at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: urs at akk dot org @ 2023-03-14  5:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109120
           Summary: False positive -Wanalyzer-malloc-leak with failed
                    iconv_open()
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: urs at akk dot org
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu
             Build: x86_64-pc-linux-gnu

Created attachment 54660
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54660&action=edit
minimal test case

gcc build from git @ a9835599fdb56f33da23e4514a9e21d8c2d51d71

with

configure --program-suffix=-13 --enable-languages=c,lto --enable-lto
--disable-multilib --enable-default-pie
make -j 12 BOOT_CFLAGS='-pipe -O0 -w' bootstrap

on

x86_64-pc-linux-gnu (AMD Ryzen 7 PRO 6850U); Debian GNU/Linux 12 (bookworm); 
Kernel 6.1.0-4-amd64; GLIBC 2.36-8

gcc-13 -v -save-temps -freport-bug -g -std=c11 -O0 -fanalyzer -c iconv.c -o
iconv

results in

iconv.c: In function ‘t’:
iconv.c:11:5: warning: leak of ‘cd’ [CWE-401] [-Wanalyzer-malloc-leak]
   11 |     return;
      |     ^~~~~~
  ‘t’: events 1-2
    |
    |    8 |     if ((cd = iconv_open("From", "To")) != (iconv_t) (-1)) {
    |      |        ~      ^~~~~~~~~~~~~~~~~~~~~~~~
    |      |        |      |
    |      |        |      (1) allocated here
    |      |        (2) following ‘false’ branch (when ‘cd ==
18446744073709551615’)...
    |
  ‘t’: event 3
    |
    |cc1:
    | (3): ...to here
    |
  ‘t’: event 4
    |
    |   11 |     return;
    |      |     ^~~~~~
    |      |     |
    |      |     (4) ‘cd’ leaks here; was allocated at (1)
    |

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

end of thread, other threads:[~2023-03-14 16:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14  5:37 [Bug analyzer/109120] New: False positive -Wanalyzer-malloc-leak with failed iconv_open() urs at akk dot org
2023-03-14 15:16 ` [Bug analyzer/109120] " dmalcolm at gcc dot gnu.org
2023-03-14 16:11 ` dmalcolm at gcc dot gnu.org
2023-03-14 16:13 ` dmalcolm at gcc dot gnu.org
2023-03-14 16:16 ` dmalcolm at gcc dot gnu.org
2023-03-14 16:31 ` [Bug analyzer/109120] False positive -Wanalyzer-malloc-leak with failed iconv_open() with glibc 2.36 onwards dmalcolm at gcc dot gnu.org
2023-03-14 16:50 ` 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).