From patchwork Mon Oct 26 03:46:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 9369 Received: (qmail 15475 invoked by alias); 26 Oct 2015 03:47:16 -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 15407 invoked by uid 89); 26 Oct 2015 03:47:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp.electronicbox.net Received: from smtp.electronicbox.net (HELO smtp.electronicbox.net) (96.127.255.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 03:47:12 +0000 Received: from simark.lan. (cable-192.222.137.139.electronicbox.net [192.222.137.139]) by smtp.electronicbox.net (Postfix) with ESMTP id 120B4440E86; Sun, 25 Oct 2015 23:47:11 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH c++ 08/12] scm-symbol.c: Add (domain_enum) casts Date: Sun, 25 Oct 2015 23:46:40 -0400 Message-Id: <1445831204-16588-8-git-send-email-simon.marchi@polymtl.ca> In-Reply-To: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> References: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> We currently pass integers as domain_enums to lookup_symbol. The most obvious fix is to add casts there. I first thought of changing the type of the domain variables to domain_enum. However, because we pass a pointer to them to gdbscm_parse_function_args, which expects them to be integers (because of the format string), I don't think it would be correct. If the enum does not have the same size as an int, gdbscm_parse_function_args could write past the memory of domain, overwriting something else on the stack. gdb/ChangeLog: * guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add domain_enum cast. (gdbscm_lookup_symbol): Likewise. --- gdb/guile/scm-symbol.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index 81e4d50..10400be 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -622,7 +622,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) TRY { - symbol = lookup_symbol (name, block, domain, &is_a_field_of_this).symbol; + symbol = lookup_symbol (name, block, (domain_enum) domain, + &is_a_field_of_this).symbol; } CATCH (ex, RETURN_MASK_ALL) { @@ -662,7 +663,7 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest) TRY { - symbol = lookup_global_symbol (name, NULL, domain).symbol; + symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; } CATCH (ex, RETURN_MASK_ALL) {