From 6dd47d34c678c3aa6eea973f2ba461f4b595668c Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Fri, 24 Oct 2008 18:21:00 +0000 Subject: [PATCH] * dwarf2read.c (typename_concat): Don't segv if prefix or suffix is NULL. Simplify obs == NULL case. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2read.c | 18 ++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ff4264b0ed..183322d2f7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2008-10-24 Doug Evans + + * dwarf2read.c (typename_concat): Don't segv if prefix or suffix + is NULL. Simplify obs == NULL case. + 2008-10-24 Hui Zhu Pedro Alves diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 840077c876..ba863fef1d 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