From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 70BEC207D6 for ; Wed, 3 May 2017 09:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752529AbdECJgT (ORCPT ); Wed, 3 May 2017 05:36:19 -0400 Received: from mout.gmx.net ([212.227.15.18]:52009 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289AbdECJgS (ORCPT ); Wed, 3 May 2017 05:36:18 -0400 Received: from virtualbox ([37.201.193.73]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LkgAG-1dg0Oh1BtE-00aUHk; Wed, 03 May 2017 11:35:59 +0200 Date: Wed, 3 May 2017 11:35:56 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@virtualbox To: Jeff King cc: Stefan Beller , "git@vger.kernel.org" , Junio C Hamano , Johannes Sixt Subject: Re: [PATCH v3 14/25] setup_discovered_git_dir(): plug memory leak In-Reply-To: <20170502181511.wxr75p2uuwc4nni2@sigill.intra.peff.net> Message-ID: References: <20170502181511.wxr75p2uuwc4nni2@sigill.intra.peff.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K0:izbpntlcqCIRAQYGdqgPCRIqlEb8xi52e4GsHW8nTXAG3FoPuQE Rh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precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Peff, On Tue, 2 May 2017, Jeff King wrote: > On Tue, May 02, 2017 at 10:20:29AM -0700, Stefan Beller wrote: > > > > - gitdir = real_pathdup(gitdir, 1); > > > + gitdir = to_free = real_pathdup(gitdir, 1); > > > if (chdir(cwd->buf)) > > > die_errno("Could not come back to cwd"); > > > > As the original motivation was to shut up Coverity, this may not > > accomplish that goal, as in the path of taking the die_errno, we do not > > free `to_free`. But that is ok as the actual goal is to hav no memleaks > > in the good case. A memleak just before a die is no big deal. > > I think Coverity understands our NORETURN attributes, so this should be > fine (and if it doesn't, then we should fix that in the model file; but > from the general results I've seen, it does). That matches my impression. Note that Coverity cannot figure out that all of our cmd_*() functions are called in code paths that exit() with their return value. Otherwise we would not see reports about those tons of intentional "let's abuse exit() as our garbage collector" instances. Ciao, Dscho