From patchwork Mon Sep 17 13:52:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 29419 Received: (qmail 123522 invoked by alias); 17 Sep 2018 13:52:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 123498 invoked by uid 89); 17 Sep 2018 13:52:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN autolearn=ham version=3.3.2 spammy=Push, Hx-languages-length:1534, referring, HContent-Transfer-Encoding:8bit X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Sep 2018 13:52:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1537192344; h=From:Sender:Reply-To:Subject:Date:Message-Id:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4a2Ukm/ToM2nCUM9ihZ55zTX5W6q/YXIp03NXGrW/U0=; b=T+72hHybCWoLvszkQh1hqZ685t6Ce20cJsjQiSZqhtxDJ53qP1EHYmSYScJymATJ jYIyfj+POsHAN7gS5SE8AZZ04LxzvxaMijIPP27seg+DsNQ1yqgnNh/5+aCgU1BX tHRGZYpqdVhczTKBRo4klprnvfADwETR40uxar2eTfI=; Received: from ESESSMB502.ericsson.se (Unknown_Domain [153.88.183.120]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 4A.51.22015.891BF9B5; Mon, 17 Sep 2018 15:52:24 +0200 (CEST) Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESSMB502.ericsson.se (153.88.183.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 17 Sep 2018 15:52:23 +0200 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Mon, 17 Sep 2018 15:52:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V6DFs2CgvWqMv1QgEK8u9bA4MKXHv4hwOOLvbiyURno=; b=F5dhzRiFarOLtZ2YIEvEfTsucI0AL2VOhZEtVuucDyHmzMgrkxKNvZmDWiKMJpVbm5QY/oRFw9gUOL+ELmwc3MDyWmCSRc0oPcCny+Nj3w3XKYZ4mLVwgxhaew2z8LwXHj8C6HNCj4qd8udOxrp9cgZ+QhHkZcbcPaTmfHfocgw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.ca.am.ericsson.se (192.75.88.130) by SN6PR15MB2398.namprd15.prod.outlook.com (2603:10b6:805:24::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Mon, 17 Sep 2018 13:52:21 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] Fix use-after-move in compile/compile-cplus-types.c Date: Mon, 17 Sep 2018 09:52:03 -0400 Message-Id: <20180917135203.10368-1-simon.marchi@ericsson.com> In-Reply-To: <82a8995b-fd73-ad0b-ed82-64cdb0b54272@redhat.com> References: <82a8995b-fd73-ad0b-ed82-64cdb0b54272@redhat.com> MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes 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))