From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id j3pdBaI5a2DHMQAAWB0awg (envelope-from ) for ; Mon, 05 Apr 2021 12:24:02 -0400 Received: by simark.ca (Postfix, from userid 112) id 02EF31E789; Mon, 5 Apr 2021 12:24:02 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 58B9D1E590 for ; Mon, 5 Apr 2021 12:24:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87B96384C002; Mon, 5 Apr 2021 16:24:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87B96384C002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617639840; bh=XlSPMkd2DJJ8UTOEF/pxxsbx1MifWII2Iri3jZQouZI=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=T9owvYLE/63287EnZvvWITSRw2wpabRW6HSdX0O6DdEyXXyjAlvglicF5gJrZYwEm OyBMEF3J2puAr0CeQG6kSrpYtQvQmXOI7lbcEH6GrE/iklRRLBOMxXnDKn3StvHViO xKaPVCd5wDwwkieAOzvOp9aTJMW9EdXKOejSVL7g= Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id F4186385803F for ; Mon, 5 Apr 2021 16:23:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F4186385803F Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8BDEF335D67; Mon, 5 Apr 2021 16:23:55 +0000 (UTC) Date: Mon, 5 Apr 2021 12:23:55 -0400 To: Simon Marchi Subject: Re: [PATCH] sim/m32c: fix memory leaks in opc2c Message-ID: Mail-Followup-To: Simon Marchi , gdb-patches@sourceware.org References: <20210405145856.3925296-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210405145856.3925296-1-simon.marchi@polymtl.ca> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 05 Apr 2021 10:58, Simon Marchi via Gdb-patches wrote: > Fix the leak in dump_lines by free-ing the elements of varnames. i dislike stuffing a bunch of free's at the end of a program's lifetime just to satisfy a tool that is not normally used. which isn't to say LSAN isn't useful, just that i think we should do better. in other codebases, i've done things like: #ifdef __SANITIZE_ADDRESS__ # define ENABLE_CLEANUP_ONEXIT 1 #else # define ENABLE_CLEANUP_ONEXIT 0 #endif then this could be written: if (ENABLE_CLEANUP_ONEXIT) { for (i = 0; i < vn; i++) free (varnames[i]); } wdyt ? feel free to bikeshed the name. not sure if there's prior art in the tree currently. -mike