Re: [PATCH v3 14/25] setup_discovered_git_dir(): plug memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]