From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 81E253858D33 for ; Wed, 15 Feb 2023 23:11:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81E253858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id E90F810047D46 for ; Wed, 15 Feb 2023 23:11:48 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id SQwGpShuuaJXNSQwGpig2d; Wed, 15 Feb 2023 23:11:48 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ZpQol/3G c=1 sm=1 tr=0 ts=63ed66b4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=_ZhYKdCeAAAA:8 a=zstS-IiYAAAA:8 a=qA-PYZtTqYEk0kYBEzcA:9 a=uqOk3ZSnBfCTOznnrPA1:22 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To: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=5JJk2ocv+NVXkyNuHqImEN3PHuiziBu+e/mbHNGAjq4=; b=s/y+v7XihLCz+gWOZqF9Ldty7F e+xuK6HRbfgjuepwC6Y03W6ZffTllZR9y5Cp7M5d63IBHGcBCcF0XDnLlv4NHC0c5cwlj/mYdACdH gs9YERARmXsrNfJJWsxUZnwZT; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:43024 helo=prentzel) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pSQwG-001Anm-HX; Wed, 15 Feb 2023 16:11:48 -0700 From: Tom Tromey To: Simon Marchi Cc: Tom Tromey , binutils@sourceware.org Subject: Re: [PATCH 7/8] Use @deftypefn in chew output References: <20230208071725.3668898-1-tom@tromey.com> <20230208071725.3668898-8-tom@tromey.com> X-Attribution: Tom Date: Wed, 15 Feb 2023 16:11:44 -0700 In-Reply-To: (Simon Marchi's message of "Wed, 15 Feb 2023 12:55:31 -0500") Message-ID: <87cz6abk27.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.130.93 X-Source-L: No X-Exim-ID: 1pSQwG-001Anm-HX X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-130-93.hlrn.qwest.net (prentzel) [75.166.130.93]:43024 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Simon" == Simon Marchi writes: Simon> Starting with this commit, I see this when building (with ASan enabled): Oops, sorry about that. This patch should fix it. Let me know what you think. Tom commit 482e9a3e3a3aee643d671d2594be709446cef065 Author: Tom Tromey Date: Wed Feb 15 16:09:35 2023 -0700 Avoid memory leak in chew An earlier patch of mine introduced a memory leak in chew. The bug was that the new "variable" word didn't free the following word. This patch fixes it by arranging to transfer ownership of the name to the variable itself. bfd/ChangeLog 2023-02-15 Tom Tromey * doc/chew.c (add_variable): New function, from add_intrinsic_variable. (add_intrinsic_variable): Call add_variable. (compile): Call add_variable. diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e160e4472df..5bf3e9f0919 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2023-02-15 Tom Tromey + + * doc/chew.c (add_variable): New function, from + add_intrinsic_variable. + (add_intrinsic_variable): Call add_variable. + (compile): Call add_variable. + 2023-02-07 Tom Tromey * bfd.c, cache.c, compress.c, opncls.c: Remove RETURNS from diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c index 19e3781bdda..cd399697abd 100644 --- a/bfd/doc/chew.c +++ b/bfd/doc/chew.c @@ -1241,9 +1241,9 @@ add_intrinsic (char *name, void (*func) (void)) } static void -add_intrinsic_variable (char *name, intptr_t *loc) +add_variable (char *name, intptr_t *loc) { - dict_type *new_d = newentry (xstrdup (name)); + dict_type *new_d = newentry (name); pcu p = { push_variable }; add_to_definition (new_d, p); p.l = (intptr_t) loc; @@ -1252,6 +1252,12 @@ add_intrinsic_variable (char *name, intptr_t *loc) add_to_definition (new_d, p); } +static void +add_intrinsic_variable (const char *name, intptr_t *loc) +{ + add_variable (xstrdup (name), loc); +} + void compile (char *string) { @@ -1333,7 +1339,7 @@ compile (char *string) continue; intptr_t *loc = xmalloc (sizeof (intptr_t)); *loc = 0; - add_intrinsic_variable (word, loc); + add_variable (word, loc); string = nextword (string, &word); } else