From 0afbabf05a1476244ef02407df531b6c7a4076dc Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 5 Mar 2020 15:02:45 -0800 Subject: [PATCH] Use std::string for 'psargs'. fbsd_make_corefile_notes leaked the memory for psargs previously. gdb/ChangeLog: * fbsd-tdep.c (fbsd_make_corefile_notes): Use std::string for psargs. --- gdb/ChangeLog | 5 +++++ gdb/fbsd-tdep.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d8c44d80e4e..ee0d10d8c98 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-03-05 John Baldwin + + * fbsd-tdep.c (fbsd_make_corefile_notes): Use std::string for + psargs. + 2020-03-05 Tankut Baris Aktemur * .gitattributes: New file. diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index bc1b5afd020..ffffb187008 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -725,14 +725,14 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) if (get_exec_file (0)) { const char *fname = lbasename (get_exec_file (0)); - char *psargs = xstrdup (fname); + std::string psargs = fname; - if (get_inferior_args ()) - psargs = reconcat (psargs, psargs, " ", get_inferior_args (), - (char *) NULL); + const char *infargs = get_inferior_args (); + if (infargs != NULL) + psargs = psargs + " " + infargs; note_data = elfcore_write_prpsinfo (obfd, note_data, note_size, - fname, psargs); + fname, psargs.c_str ()); } /* Thread register information. */ -- 2.30.2