Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] Use std::string for 'psargs'.
Date: Thu, 05 Mar 2020 23:07:00 -0000	[thread overview]
Message-ID: <20200305230658.89374-1-jhb@FreeBSD.org> (raw)

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 d8c44d80e4..ee0d10d8c9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-05  John Baldwin  <jhb@FreeBSD.org>
+
+	* fbsd-tdep.c (fbsd_make_corefile_notes): Use std::string for
+	psargs.
+
 2020-03-05  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
 	* .gitattributes: New file.
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index bc1b5afd02..ffffb18700 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.23.0


             reply	other threads:[~2020-03-05 23:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 23:07 John Baldwin [this message]
2020-03-05 23:15 ` Simon Marchi
2020-03-05 23:58   ` John Baldwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200305230658.89374-1-jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox