Bug 31131 - Potential Memory Leak in wrstabs.c
Summary: Potential Memory Leak in wrstabs.c
Status: RESOLVED OBSOLETE
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-10 07:01 UTC by yuxuan He
Modified: 2023-12-11 01:51 UTC (History)
0 users

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


Attachments
picture showing the potential bug (169.93 KB, image/png)
2023-12-10 07:01 UTC, yuxuan He
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yuxuan He 2023-12-10 07:01:19 UTC
Created attachment 15250 [details]
picture showing the potential bug

hi, i found a potential memory leak located in binutils/wrstabs.c, function write_stabs_in_sections_debugging_info

step1: call xmalloc to allocate memory and store it in local variable "info"

steo2: there are several paths can leak the memory, for example, if the expression in if-statement "if (! stab_write_symbol (&info, 0, 0, 0, (const char *) NULL))" is true, then return False, and memory leaked.

i post a picture as an attachment to show the potential bug.

can you help to check whether this bug is true? thank you very much
Comment 1 Alan Modra 2023-12-10 21:00:48 UTC
Already fixed.  2.32 is old.  You should look at current source if you want to help improve binutils.  git clone https://sourceware.org/git/binutils-gdb.git
Comment 2 yuxuan He 2023-12-11 01:50:14 UTC
(In reply to Alan Modra from comment #1)
> Already fixed.  2.32 is old.  You should look at current source if you want
> to help improve binutils.  git clone
> https://sourceware.org/git/binutils-gdb.git

thanks for your reply. 2.32 is old but i've check this bug still existing in current version. and there are several system still use 2.32 as there default version.for example, ubuntu 18.04.
Comment 3 yuxuan He 2023-12-11 01:51:37 UTC
thanks for your reply. 2.32 is old but i've check this bug still existing in current version. and there are several system still use 2.32 as there default version.for example, ubuntu 18.04.