Bug 29261 - A Potential Memory Leak Bug
Summary: A Potential Memory Leak Bug
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.39
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-18 02:41 UTC by yuxuan He
Modified: 2022-06-20 02:10 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
diagram of memory leak bug (113.57 KB, image/png)
2022-06-18 02:41 UTC, yuxuan He
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yuxuan He 2022-06-18 02:41:58 UTC
Created attachment 14150 [details]
diagram of memory leak bug

Hi, I found a potential memory leak bug in the project source code of binutils, I have shown the execution sequence of the program that may generate the bug on a diagram which is added to the attachment.
The text in red illustrates the steps that generate the bug
The red arrows represent call relationships
The green text illustrates the files and functions whose code snippets are located below the green text.

In short, the key to the bug is the third step in the diagram. In the third step, when select the true branch, program will directly "return FALSE", instead of doing the free operation like the red box in the figure.


I look forward to your reply and thank you very much for your patience!
Comment 1 cvs-commit@gcc.gnu.org 2022-06-20 01:51:45 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8a24927bc8dbf6beac2000593b21235c3796dc35

commit 8a24927bc8dbf6beac2000593b21235c3796dc35
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Jun 20 10:39:13 2022 +0930

    PR29261, memory leak in parse_stab_struct_fields
    
            PR 29261
            * stabs.c (parse_stab_struct_fields): Free "fields" on failure path.
Comment 2 Alan Modra 2022-06-20 02:10:11 UTC
Fixed.