Re: [PATCH v3 14/25] setup_discovered_git_dir(): plug memory leak
- From
Jeff King <peff@peff.net>
- Date
- May 2, 2017, 18:15 UTC
- Message-ID
- <20170502181511.wxr75p2uuwc4nni2@sigill.intra.peff.net>
- In-Reply-To
- <CAGZ79kbsy1qh02WjX0nt6ci4r+5DVxJcPzwburBf0TP0qaEMTA@mail.gmail.com>
On Tue, May 02, 2017 at 10:20:29AM -0700, Stefan Beller wrote:
Show 9 quoted lines
> > - 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