aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2008-10-24 18:21:00 +0000
committerDoug Evans <dje@google.com>2008-10-24 18:21:00 +0000
commit6dd47d34c678c3aa6eea973f2ba461f4b595668c (patch)
treed6c8f2ab18362d9de0e8ec489f7c28b677c9048e /gdb/dwarf2read.c
parentfff08868842909b8dda5539656727196f812f7b1 (diff)
downloadgdb-6dd47d34c678c3aa6eea973f2ba461f4b595668c.zip
gdb-6dd47d34c678c3aa6eea973f2ba461f4b595668c.tar.gz
gdb-6dd47d34c678c3aa6eea973f2ba461f4b595668c.tar.bz2
* dwarf2read.c (typename_concat): Don't segv if prefix or suffix
is NULL. Simplify obs == NULL case.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 840077c..ba863fe 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8081,19 +8081,17 @@ typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
else
sep = "::";
+ if (prefix == NULL)
+ prefix = "";
+ if (suffix == NULL)
+ suffix = "";
+
if (obs == NULL)
{
char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
- retval[0] = '\0';
-
- if (prefix)
- {
- strcpy (retval, prefix);
- strcat (retval, sep);
- }
- if (suffix)
- strcat (retval, suffix);
-
+ strcpy (retval, prefix);
+ strcat (retval, sep);
+ strcat (retval, suffix);
return retval;
}
else