aboutsummaryrefslogtreecommitdiff
path: root/gas/remap.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2011-03-11 14:18:24 +0000
committerNick Clifton <nickc@redhat.com>2011-03-11 14:18:24 +0000
commit502df130577339e30647c32a728b01c2fe99e78e (patch)
treee95301c187328674b6401a649eecfc81d5695df5 /gas/remap.c
parentf2eb0bc849b3c5598d02a2b83b2cef29312a171d (diff)
downloadgdb-502df130577339e30647c32a728b01c2fe99e78e.zip
gdb-502df130577339e30647c32a728b01c2fe99e78e.tar.gz
gdb-502df130577339e30647c32a728b01c2fe99e78e.tar.bz2
* remap.c (remap_debug_filename): Always allocate a buffer for the
returned pointer. * stabs.c (stabs_generate_asm_file): Free the pointer returned by remap_debug_filename.
Diffstat (limited to 'gas/remap.c')
-rw-r--r--gas/remap.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gas/remap.c b/gas/remap.c
index 0c863fb..ae9b9dd 100644
--- a/gas/remap.c
+++ b/gas/remap.c
@@ -65,8 +65,9 @@ add_debug_prefix_map (const char *arg)
debug_prefix_maps = map;
}
-/* Perform user-specified mapping of debug filename prefixes. Return
- the new name corresponding to FILENAME. */
+/* Perform user-specified mapping of debug filename prefixes. Returns
+ a newly allocated buffer containing the name corresponding to FILENAME.
+ It is the caller's responsibility to free the buffer. */
const char *
remap_debug_filename (const char *filename)
@@ -80,7 +81,7 @@ remap_debug_filename (const char *filename)
if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0)
break;
if (!map)
- return filename;
+ return xstrdup (filename);
name = filename + map->old_len;
name_len = strlen (name) + 1;
s = (char *) alloca (name_len + map->new_len);