From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84186 invoked by alias); 23 Sep 2018 04:08:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 84072 invoked by uid 89); 23 Sep 2018 04:08:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_RP_RNBL,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*RU:sk:gateway, Hx-spam-relays-external:sk:gateway, byte_order, latent X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.144.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Sep 2018 04:08:20 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 42E8FDB4B0 for ; Sat, 22 Sep 2018 23:08:19 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 3vgxgVzIakBj63vgxgf47U; Sat, 22 Sep 2018 23:08:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=f5334xLFM/yhkeTgbp+uxYqDPsOigRH5Y/epQiHCV88=; b=gQ/cA07kfgRufo5WJvrQds3qta qKRbKNCJw/IGMQQNuJzHiBJuIDbXO3SCVyAWBs0cRZ0riPx8HtpbGl9C7LC9VshUzpDFNnHUPx/js vfWMrnrfqz/6D8YUN9iSOZoD6; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:37440 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g3vgx-002UJa-1L; Sat, 22 Sep 2018 23:08:19 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/8] Fix latent bug in msp430-tdep.c Date: Sun, 23 Sep 2018 04:08:00 -0000 Message-Id: <20180923040814.27941-6-tom@tromey.com> In-Reply-To: <20180923040814.27941-1-tom@tromey.com> References: <20180923040814.27941-1-tom@tromey.com> X-SW-Source: 2018-09/txt/msg00761.txt.bz2 -Wshadow=local found this latent bug. msp430-tdep.c does: const gdb_byte *arg_bits; { /* Aggregates of any size are passed by reference. */ gdb_byte struct_addr[4]; [... arg_bits = struct_addr; } ... use arg_bits Here, arg_bits can point to an object that's gone out of scope. The fix is to hoist the inner "struct_addr" buffer to an outer scope, and rename it to avoid shadowing. gdb/ChangeLog 2018-09-22 Tom Tromey * msp430-tdep.c (msp430_push_dummy_call): Rename inner "structs_addr" and hoist declaration. --- gdb/ChangeLog | 5 +++++ gdb/msp430-tdep.c | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index b6e062a380..427f58c0ed 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -715,6 +715,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ULONGEST arg_size = TYPE_LENGTH (arg_type); int offset; int current_arg_on_stack; + gdb_byte struct_addr_buf[4]; current_arg_on_stack = 0; @@ -722,11 +723,9 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, || TYPE_CODE (arg_type) == TYPE_CODE_UNION) { /* Aggregates of any size are passed by reference. */ - gdb_byte struct_addr[4]; - - store_unsigned_integer (struct_addr, 4, byte_order, + store_unsigned_integer (struct_addr_buf, 4, byte_order, value_address (arg)); - arg_bits = struct_addr; + arg_bits = struct_addr_buf; arg_size = (code_model == MSP_LARGE_CODE_MODEL) ? 4 : 2; } else -- 2.17.1