From: Jeff King Date: Wed, 26 Aug 2015 17:06:48 GMT Subject: Re: [PATCH 3/5] submodule: helper to run foreach in parallel Message-ID: <20150826170647.GA1870@sigill.intra.peff.net> In-Reply-To: <1440523706-23041-4-git-send-email-sbeller@google.com> On Tue, Aug 25, 2015 at 10:28:24AM -0700, Stefan Beller wrote: > +int module_foreach_parallel(int argc, const char **argv, const char *prefix) > +{ > [...] > + for (i = 0; i < ce_used; i++) { > + const struct submodule *sub; > + const struct cache_entry *ce = ce_entries[i]; > + struct submodule_args *args = malloc(sizeof(*args)); > + > + if (ce_stage(ce)) > + args->sha1 = xstrdup(sha1_to_hex(null_sha1)); > + else > + args->sha1 = xstrdup(sha1_to_hex(ce->sha1)); > + > + strbuf_reset(&sb); > + strbuf_addf(&sb, "%s/.git", ce->name); > + if (!file_exists(sb.buf)) > + continue; "args" and "args->sha1" go out of scope and leak here. > + args->name = sub->name; > + args->toplevel = xstrdup(xgetcwd()); Another xgetcwd leak. :) I think this one can just drop the xstrdup. (Both of these were spotted by Coverity. I know you have played with it a little, so if you are actually reading the emails it sends, I'll stop relaying them). -Peff