]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
s390: s390_machinemode leak
authorJens Remus <jremus@linux.ibm.com>
Mon, 27 Jan 2025 15:43:39 +0000 (16:43 +0100)
committerJens Remus <jremus@linux.ibm.com>
Mon, 27 Jan 2025 15:43:39 +0000 (16:43 +0100)
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>
gas/config/tc-s390.c

index e7a7e7e04f1f32e5ef2d0eec335f75f1e60a7446..113b9f41a1ece0493590b191103f85af59a09f73 100644 (file)
@@ -2287,6 +2287,7 @@ s390_machinemode (int ignore ATTRIBUTE_UNUSED)
        s390_setup_opcodes ();
     }
 
+  xfree (mode_string);
   demand_empty_rest_of_line ();
 }