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.8 required=3.0 tests=AWL,BAYES_00, 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 4D5E81F790 for ; Tue, 2 May 2017 18:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751156AbdEBSPQ (ORCPT ); Tue, 2 May 2017 14:15:16 -0400 Received: from cloud.peff.net ([104.130.231.41]:44099 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751137AbdEBSPP (ORCPT ); Tue, 2 May 2017 14:15:15 -0400 Received: (qmail 7298 invoked by uid 109); 2 May 2017 18:15:14 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.84) with SMTP; Tue, 02 May 2017 18:15:14 +0000 Received: (qmail 16446 invoked by uid 111); 2 May 2017 18:15:41 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.84) with SMTP; Tue, 02 May 2017 14:15:41 -0400 Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Tue, 02 May 2017 14:15:11 -0400 Date: Tue, 2 May 2017 14:15:11 -0400 From: Jeff King To: Stefan Beller Cc: Johannes Schindelin , "git@vger.kernel.org" , Junio C Hamano , Johannes Sixt Subject: Re: [PATCH v3 14/25] setup_discovered_git_dir(): plug memory leak Message-ID: <20170502181511.wxr75p2uuwc4nni2@sigill.intra.peff.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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). -Peff