[binutils-gdb] s390: s390_machinemode leak

Jens Remus jremus@sourceware.org
Mon Jan 27 15:44:51 GMT 2025


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

commit 4bda1fb42f3ba7b06d38a9f8277c40ad37226a51
Author: Jens Remus <jremus@linux.ibm.com>
Date:   Mon Jan 27 16:43:39 2025 +0100

    s390: s390_machinemode leak
    
    This resolves the following memory leak reported by ASAN:
    
    Direct leak of 17 byte(s) in 1 object(s) allocated from:
        #0 0x3ffb32fbb1d in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
        #1 0x2aa149861cf in xmalloc ../../libiberty/xmalloc.c:149
        #2 0x2aa149868ff in xstrdup ../../libiberty/xstrdup.c:34
        #3 0x2aa1312391f in s390_machinemode ../../gas/config/tc-s390.c:2241
        #4 0x2aa130ddc7b in read_a_source_file ../../gas/read.c:1293
        #5 0x2aa1304f7bf in perform_an_assembly_pass ../../gas/as.c:1223
        #6 0x2aa1304f7bf in main ../../gas/as.c:1436
        #7 0x3ffb282be35 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
        #8 0x3ffb282bf33 in __libc_start_main_impl ../csu/libc-start.c:360
        #9 0x2aa1305758f  (/home/jremus/git/binutils/build-asan/gas/as-new+0x2d5758f) (BuildId: ...)
    
    gas/
            * config/tc-s390.c (s390_machinemode): Free mode_string before
            returning.
    
    Signed-off-by: Jens Remus <jremus@linux.ibm.com>

Diff:
---
 gas/config/tc-s390.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index e7a7e7e04f1..113b9f41a1e 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -2287,6 +2287,7 @@ s390_machinemode (int ignore ATTRIBUTE_UNUSED)
 	s390_setup_opcodes ();
     }
 
+  xfree (mode_string);
   demand_empty_rest_of_line ();
 }


More information about the Binutils-cvs mailing list