From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C8F923858D32; Tue, 14 Mar 2023 05:37:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8F923858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678772253; bh=SmjE4VXQddytirehT/Y0N16sCtBhVRqaGCjSBnxBGGo=; h=From:To:Subject:Date:From; b=LDTEOz8X/3v+T3ncY/55Xx+xxvKWxk3S4Vuq8fVnIUh4uOyfsM4sI+W6aEjf7x+tm 4xGZfbvaBe8FjBXdBTUaLOdEjrbkdZS47EpY0hsLWhYORfa1FIQLe+n1WrJsmJmkax 69lsWeWiVI2KrhEbImEW3dUqi+u0latHdjQTIQFo= From: "urs at akk dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/109120] New: False positive -Wanalyzer-malloc-leak with failed iconv_open() Date: Tue, 14 Mar 2023 05:37:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: urs at akk dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcchost cf_gcctarget cf_gccbuild attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109120 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=3D54660&action=3Dedit minimal test case gcc build from git @ a9835599fdb56f33da23e4514a9e21d8c2d51d71 with configure --program-suffix=3D-13 --enable-languages=3Dc,lto --enable-lto --disable-multilib --enable-default-pie make -j 12 BOOT_CFLAGS=3D'-pipe -O0 -w' bootstrap on x86_64-pc-linux-gnu (AMD Ryzen 7 PRO 6850U); Debian GNU/Linux 12 (bookworm)= ;=20 Kernel 6.1.0-4-amd64; GLIBC 2.36-8 gcc-13 -v -save-temps -freport-bug -g -std=3Dc11 -O0 -fanalyzer -c iconv.c = -o iconv results in iconv.c: In function =E2=80=98t=E2=80=99: iconv.c:11:5: warning: leak of =E2=80=98cd=E2=80=99 [CWE-401] [-Wanalyzer-m= alloc-leak] 11 | return; | ^~~~~~ =E2=80=98t=E2=80=99: events 1-2 | | 8 | if ((cd =3D iconv_open("From", "To")) !=3D (iconv_t) (-1))= { | | ~ ^~~~~~~~~~~~~~~~~~~~~~~~ | | | | | | | (1) allocated here | | (2) following =E2=80=98false=E2=80=99 branch (when =E2= =80=98cd =3D=3D 18446744073709551615=E2=80=99)... | =E2=80=98t=E2=80=99: event 3 | |cc1: | (3): ...to here | =E2=80=98t=E2=80=99: event 4 | | 11 | return; | | ^~~~~~ | | | | | (4) =E2=80=98cd=E2=80=99 leaks here; was allocated at (1) |=