Bug 29262 - A Potential Memory Leak Bug
Summary: A Potential Memory Leak Bug
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.39
Assignee: Alan Modra
Depends on:
Reported: 2022-06-18 02:47 UTC by yuxuan He
Modified: 2022-06-20 07:27 UTC (History)
0 users

See Also:
Last reconfirmed:

diagram of memory leak bug (82.47 KB, image/png)
2022-06-18 02:47 UTC, yuxuan He

Note You need to log in before you can comment on or make changes to this bug.
Description yuxuan He 2022-06-18 02:47:43 UTC
Created attachment 14151 [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 the true branch is selected, the program will directly "return FALSE" instead of doing a free operation on 's',and the function call in the condition statement does not do a free operation on 's', which leads to a memory leak.

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:50 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:


commit 0d02e70b197c786f26175b9a73f94e01d14abdab
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Jun 20 10:39:31 2022 +0930

    PR29262, memory leak in pr_function_type
            PR 29262
            * prdbg.c (pr_function_type): Free "s" on failure path.
Comment 2 Alan Modra 2022-06-20 02:10:29 UTC
Comment 3 yuxuan He 2022-06-20 07:27:46 UTC
(In reply to Alan Modra from comment #2)
> Fixed.

Thank you.