Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH] Fix use-after-move in compile/compile-cplus-types.c
Date: Mon, 17 Sep 2018 13:52:00 -0000	[thread overview]
Message-ID: <20180917135203.10368-1-simon.marchi@ericsson.com> (raw)
In-Reply-To: <82a8995b-fd73-ad0b-ed82-64cdb0b54272@redhat.com>

Patch

  d82b3862f12 ("compile: Remove non-const reference parameters")

introduced a regression in compile/compile-cplus-types.c.  The new_scope
variable in compile_cplus_instance::enter_scope is used after it was
std::moved.  This patch fixes it by referring to the back of the vector
where it was moved instead.

gdb/ChangeLog:

	* compile/compile-cplus-types.c
	(compile_cplus_instance::enter_scope): Don't use new_scope after
	std::move.
---
 gdb/compile/compile-cplus-types.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 75193d2e75b..996fea56986 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -261,7 +261,7 @@ compile_cplus_instance::enter_scope (compile_scope &&new_scope)
       if (debug_compile_cplus_scopes)
 	{
 	  fprintf_unfiltered (gdb_stdlog, "entering new scope %s\n",
-			      host_address_to_string (&new_scope));
+			      host_address_to_string (&m_scopes.back ()));
 	}
 
       /* Push the global namespace. */
@@ -270,7 +270,7 @@ compile_cplus_instance::enter_scope (compile_scope &&new_scope)
       /* Push all other namespaces.  Note that we do not push the last
 	 scope_component -- that's the actual type we are converting.  */
       std::for_each
-	(new_scope.begin (), new_scope.end () - 1,
+	(m_scopes.back ().begin (), m_scopes.back ().end () - 1,
 	 [this] (const scope_component &comp)
 	 {
 	  gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol))
-- 
2.19.0


  reply	other threads:[~2018-09-17 13:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 16:47 [PATCH] compile: Remove non-const reference parameters Simon Marchi
2018-08-30 21:57 ` Keith Seitz
2018-08-31 14:41   ` Tom Tromey
2018-09-06 10:27     ` Simon Marchi
2018-09-06 12:43       ` Tom Tromey
2018-09-06 12:49         ` Simon Marchi
2018-09-17  6:32 ` Tom Tromey
2018-09-17 13:29   ` Keith Seitz
2018-09-17 13:52     ` Simon Marchi [this message]
2018-09-17 15:25       ` [PATCH] Fix use-after-move in compile/compile-cplus-types.c Keith Seitz
2018-09-17 17:10         ` Simon Marchi

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=20180917135203.10368-1-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --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