Bug 25363 - memory leak in nm, display_rel_file
Summary: memory leak in nm, display_rel_file
Status: RESOLVED DUPLICATE of bug 25362
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: 2020-01-10 14:38 UTC by Heqing HUANG
Modified: 2020-01-13 09:16 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments
POC file (2.39 KB, application/x-sharedlib)
2020-01-10 14:38 UTC, Heqing HUANG
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Heqing HUANG 2020-01-10 14:38:02 UTC
Created attachment 12184 [details]
POC file

Hi, there.

There is a memory leak in file binutils/nm.c, get_data function.

Here is the reproducing environment and procedure:

Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial
gcc:            5.4.0

compilation:
CFLAGS="-fsanitize=address,undefined" ./configure

run:
./nm-new -C -a -l --synthetic poc

Here is the error message:

=================================================================
==66785==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7ffff6f02602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7fbefb in xmalloc (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/nm-new+0x7fbefb)
    #2 0x409f2e in display_rel_file (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/nm-new+0x409f2e)
    #3 0x40b1df in display_file (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/nm-new+0x40b1df)
    #4 0x40db2a in main (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/nm-new+0x40db2a)
    #5 0x7ffff5baf82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).
Comment 1 Alan Modra 2020-01-13 09:16:52 UTC
Same leak shown by pr25362 testcase

*** This bug has been marked as a duplicate of bug 25362 ***