git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org, gitster@pobox.com, Jens.Lehmann@web.de,
	hvoigt@hvoigt.net
Subject: Re: [PATCH 7/7] submodule: implement `module_clone` as a builtin helper
Date: Fri, 21 Aug 2015 10:22:12 -0400	[thread overview]
Message-ID: <20150821142212.GA26130@sigill.intra.peff.net> (raw)
In-Reply-To: <1439857323-21048-8-git-send-email-sbeller@google.com>

On Mon, Aug 17, 2015 at 05:22:03PM -0700, Stefan Beller wrote:

> +static int module_clone(int argc, const char **argv, const char *prefix)
> [...]
> +	/* Redirect the worktree of the submodule in the superprojects config */
> +	if (!is_absolute_path(sm_gitdir)) {
> +		char *s = (char*)sm_gitdir;
> +		strbuf_addf(&sb, "%s/%s", xgetcwd(), sm_gitdir);

Coverity noticed that this is a leak; xgetcwd actually returns a newly
allocated buffer. I think you just want:

  if (strbuf_getcwd(&sb))
	die_errno("unable to get current working directory");
  strbuf_addf("/%s", sm_gitdir);

> +		sm_gitdir = strbuf_detach(&sb, NULL);
> +		strbuf_reset(&sb);

This reset is a noop after you've detached. It's not technically
documented, but I do not think it is reasonable for it to work any other
way. Maybe strbuf.h should make that promise.

> +	strbuf_addf(&sb, "%s/%s", xgetcwd(), path);

Ditto on the xgetcwd issue here.

-Peff

  parent reply	other threads:[~2015-08-21 14:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18  0:21 [PATCH 0/7] Submodule improvements Stefan Beller
2015-08-18  0:21 ` [PATCH 1/7] submodule: implement a config API for lookup of .gitmodules values Stefan Beller
2015-08-18  0:21 ` [PATCH 2/7] submodule: extract functions for config set and lookup Stefan Beller
2015-08-18  0:21 ` [PATCH 3/7] submodule: use new config API for worktree configurations Stefan Beller
2015-08-18  0:22 ` [PATCH 4/7] submodule: Allow errornous values for the fetchrecursesubmodules option Stefan Beller
2015-08-19 18:09   ` Junio C Hamano
2015-08-18  0:22 ` [PATCH 5/7] submodule: implement `module_list` as a builtin helper Stefan Beller
2015-08-19 18:17   ` Junio C Hamano
2015-08-19 18:22     ` Junio C Hamano
2015-08-19 18:25       ` Stefan Beller
2015-08-19 18:23     ` Stefan Beller
2015-08-18  0:22 ` [PATCH 6/7] submodule: implement `module_name` " Stefan Beller
2015-08-18  0:22 ` [PATCH 7/7] submodule: implement `module_clone` " Stefan Beller
2015-08-18  0:26   ` Stefan Beller
2015-08-18 22:13   ` Stefan Beller
2015-08-19 19:08     ` Junio C Hamano
2015-08-19 19:20       ` Stefan Beller
2015-08-21 14:22   ` Jeff King [this message]
2015-08-18  0:38 ` [PATCH 0/7] Submodule improvements Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150821142212.GA26130@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hvoigt@hvoigt.net \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).