diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2009-11-02 14:57:02 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2009-11-02 14:57:02 +0000 |
commit | 25522fae98c65c0c8558a07638e7a5e15ed6ca1f (patch) | |
tree | 1162da3ee7fc9dfdc8985b485b433f334d559ade | |
parent | 287ccc17edcb68ea6ba15be621e72e5bf7f46038 (diff) | |
download | binutils-gdb-25522fae98c65c0c8558a07638e7a5e15ed6ca1f.tar.gz |
gdb/
* symfile.c (find_separate_debug_file): Initialize dir, debugfile and
canon_name to NULL. Change alloca to xmalloc, newly call xfree for it.
New label cleanup_return_debugfile, jump to it from the failure paths.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/symfile.c | 59 |
2 files changed, 26 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0a92fb68906..8ab67630205 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com> + + * symfile.c (find_separate_debug_file): Initialize dir, debugfile and + canon_name to NULL. Change alloca to xmalloc, newly call xfree for it. + New label cleanup_return_debugfile, jump to it from the failure paths. + 2009-11-02 Andrew Cagney <cagney@gnu.org> * symfile.c (separate_debug_file_exists): When the CRCs mismatch diff --git a/gdb/symfile.c b/gdb/symfile.c index 75cb0f8e999..bd0a4291046 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1333,11 +1333,10 @@ static char * find_separate_debug_file (struct objfile *objfile) { asection *sect; - char *basename; - char *dir; - char *debugfile; - char *name_copy; - char *canon_name; + char *basename, *name_copy; + char *dir = NULL; + char *debugfile = NULL; + char *canon_name = NULL; bfd_size_type debuglink_size; unsigned long crc32; int i; @@ -1366,7 +1365,7 @@ find_separate_debug_file (struct objfile *objfile) if (basename == NULL) /* There's no separate debug info, hence there's no way we could load it => no warning. */ - return NULL; + goto cleanup_return_debugfile; dir = xstrdup (objfile->name); @@ -1388,24 +1387,19 @@ find_separate_debug_file (struct objfile *objfile) if (canon_name && strlen (canon_name) > i) i = strlen (canon_name); - debugfile = alloca (strlen (debug_file_directory) + 1 - + i - + strlen (DEBUG_SUBDIRECTORY) - + strlen ("/") - + strlen (basename) - + 1); + debugfile = xmalloc (strlen (debug_file_directory) + 1 + + i + + strlen (DEBUG_SUBDIRECTORY) + + strlen ("/") + + strlen (basename) + + 1); /* First try in the same directory as the original file. */ strcpy (debugfile, dir); strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); - xfree (canon_name); - return xstrdup (debugfile); - } + goto cleanup_return_debugfile; /* Then try in the subdirectory named DEBUG_SUBDIRECTORY. */ strcpy (debugfile, dir); @@ -1414,12 +1408,7 @@ find_separate_debug_file (struct objfile *objfile) strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); - xfree (canon_name); - return xstrdup (debugfile); - } + goto cleanup_return_debugfile; /* Then try in the global debugfile directory. */ strcpy (debugfile, debug_file_directory); @@ -1428,12 +1417,7 @@ find_separate_debug_file (struct objfile *objfile) strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (basename); - xfree (dir); - xfree (canon_name); - return xstrdup (debugfile); - } + goto cleanup_return_debugfile; /* If the file is in the sysroot, try using its base path in the global debugfile directory. */ @@ -1447,20 +1431,17 @@ find_separate_debug_file (struct objfile *objfile) strcat (debugfile, basename); if (separate_debug_file_exists (debugfile, crc32, objfile->name)) - { - xfree (canon_name); - xfree (basename); - xfree (dir); - return xstrdup (debugfile); - } + goto cleanup_return_debugfile; } - if (canon_name) - xfree (canon_name); + xfree (debugfile); + debugfile = NULL; +cleanup_return_debugfile: + xfree (canon_name); xfree (basename); xfree (dir); - return NULL; + return debugfile; } |