Thread (151 messages) 151 messages, 6 authors, 2017-05-11

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

From: Johannes Schindelin <hidden>
Date: 2017-05-03 09:36:28

Hi Peff,

On Tue, 2 May 2017, Jeff King wrote:
On Tue, May 02, 2017 at 10:20:29AM -0700, Stefan Beller wrote:
quoted
quoted
-                       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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help