From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.5 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 891551F97E for ; Fri, 23 Nov 2018 10:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393859AbeKWU5X (ORCPT ); Fri, 23 Nov 2018 15:57:23 -0500 Received: from mout.gmx.net ([212.227.15.15]:60043 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390102AbeKWU5X (ORCPT ); Fri, 23 Nov 2018 15:57:23 -0500 Received: from [192.168.0.129] ([37.201.193.149]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MTSKd-1fxmUK2u2R-00SM2C; Fri, 23 Nov 2018 11:13:43 +0100 Date: Fri, 23 Nov 2018 11:13:44 +0100 (STD) From: Johannes Schindelin X-X-Sender: virtualbox@gitforwindows.org To: Pranit Bauva cc: =?UTF-8?Q?Martin_=C3=85gren?= , Tanushree Tumane , Git List Subject: Re: [PATCH v16 Part II 2/8] bisect--helper: `bisect_write` shell function in C In-Reply-To: Message-ID: References: <0102015f5e5ee22c-ea9c3a38-5d42-4dce-a54b-45c59768a70b-000000@eu-west-1.amazonses.com> <20171027172845.15437-1-martin.agren@gmail.com> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323328-1806073205-1542968025=:41" X-Provags-ID: V03:K1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pecRe8USU4gUqQhSwF CjSqEpPYDWzBWNwUx2sKmF+UtNNJc7q5JRp84JKBYdayH9e2BfHnFXCyz0bLlOd7EF4GTSUAI nk2VAULJ6SnIuMLVPELo2NzhXIvlhWVMbhPHKRZEtASUf8caAh3lT14IIPTs/z Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1806073205-1542968025=:41 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Hi Pranit, (Cc:ing Tanushree because they will try to pick up this patch series as part of the Outreachy program.) On Mon, 30 Oct 2017, Pranit Bauva wrote: > On Fri, Oct 27, 2017 at 10:58 PM, Martin Ă…gren wrote: > > On 27 October 2017 at 17:06, Pranit Bauva wrote: > >> +static void free_terms(struct bisect_terms *terms) > >> +{ > >> + if (!terms->term_good) > >> + free((void *) terms->term_good); > >> + if (!terms->term_bad) > >> + free((void *) terms->term_bad); > >> +} > > > > These look like no-ops. Remove `!` for correctness, or `if (...)` for > > simplicity, since `free()` can handle NULL. > > I probably forgot to do this here. I will make the change. > > > You leave the pointers dangling, but you're ok for now since this is the > > last thing that happens in `cmd_bisect__helper()`. Your later patches > > add more users, but they're also ok, since they immediately assign new > > values. > > > > In case you (and others) find it useful, the below is a patch I've been > > sitting on for a while as part of a series to plug various memory-leaks. > > `FREE_AND_NULL_CONST()` would be useful in precisely these situations. > > Honestly, I wouldn't be the best person to judge this. Git's source code implicitly assumes that any `const` pointer refers to memory owned by another code path. It is therefore probably not a good idea to encourage `free()`ing a `const` pointer. Which brings me back to the question: who really owns that allocated memory to which `term_good` and `term_bad` refer? Ciao, Johannes --8323328-1806073205-1542968025=:41--