From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9207238582BF; Mon, 1 Aug 2022 16:07:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9207238582BF From: "godlygeek at gmail dot com" To: elfutils-devel@sourceware.org Subject: [Bug libdw/29434] New: Memory leak in `dwarf_getscopes` Date: Mon, 01 Aug 2022 16:07:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: libdw X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: godlygeek at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot 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 cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 16:07:49 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29434 Bug ID: 29434 Summary: Memory leak in `dwarf_getscopes` Product: elfutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: libdw Assignee: unassigned at sourceware dot org Reporter: godlygeek at gmail dot com CC: elfutils-devel at sourceware dot org Target Milestone: --- Found by valgrind: =3D=3D173857=3D=3D 64 bytes in 2 blocks are definitely lost in loss record = 3,155 of 8,232 =3D=3D173857=3D=3D at 0x480B7BB: malloc (vg_replace_malloc.c:380) =3D=3D173857=3D=3D by 0x90143DC: pc_record (in /path/to/python_extension_module.cpython-38-x86_64-linux-gnu.so) =3D=3D173857=3D=3D by 0x9019ABC: walk_children (in /path/to/python_extension_module.cpython-38-x86_64-linux-gnu.so) =3D=3D173857=3D=3D by 0x901974A: __libdw_visit_scopes (in /path/to/python_extension_module.cpython-38-x86_64-linux-gnu.so) =3D=3D173857=3D=3D by 0x9019A69: walk_children (in /path/to/python_extension_module.cpython-38-x86_64-linux-gnu.so) =3D=3D173857=3D=3D by 0x901974A: __libdw_visit_scopes (in /path/to/python_extension_module.cpython-38-x86_64-linux-gnu.so) =3D=3D173857=3D=3D by 0x9014691: dwarf_getscopes (in /path/to/python_extension_module.cpython-38-x86_64-linux-gnu.so) `dwarf_getscopes` ends with: ``` if (result > 0) *scopes =3D a.scopes; return result; ``` but this is incorrect, since `a.scopes` may be non-NULL even if `result` is= <=3D 0 and is leaked in this case since no reference is retained to it. Seems li= ke this needs to be: ``` if (result > 0) *scopes =3D a.scopes; else free(a.scopes); return result; ``` --=20 You are receiving this mail because: You are on the CC list for the bug.=