Bug 29261

Summary: A Potential Memory Leak Bug
Product: binutils Reporter: yuxuan He <1157401338>
Component: binutilsAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 2.34   
Target Milestone: 2.39   
Host: Target:
Build: Last reconfirmed:
Attachments: diagram of memory leak 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 Sourceware Commits 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.