git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/6] prefix_filename: return newly allocated string
Date: Tue, 21 Mar 2017 11:14:23 -0700
Message-ID: <xmqqinn2qyyo.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170321012847.yebhpdmk5zrizgmj@sigill.intra.peff.net>

Jeff King <peff@peff.net> writes:

> diff --git a/worktree.c b/worktree.c
> index 42dd3d52b..2520fc65c 100644
> --- a/worktree.c
> +++ b/worktree.c
> @@ -250,16 +250,19 @@ struct worktree *find_worktree(struct worktree **list,
>  {
>  	struct worktree *wt;
>  	char *path;
> +	char *to_free;
>  
>  	if ((wt = find_worktree_by_suffix(list, arg)))
>  		return wt;
>  
> -	arg = prefix_filename(prefix, arg);
> +	if (prefix)
> +		arg = to_free = prefix_filename(prefix, arg);
>  	path = real_pathdup(arg, 1);
>  	for (; *list; list++)
>  		if (!fspathcmp(path, real_path((*list)->path)))
>  			break;
>  	free(path);
> +	free(to_free);
>  	return *list;
>  }

worktree.c:265:6: error: to_free may be used uninitialized in this function
---
 worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/worktree.c b/worktree.c
index 2520fc65cc..bae787cf8d 100644
--- a/worktree.c
+++ b/worktree.c
@@ -250,7 +250,7 @@ struct worktree *find_worktree(struct worktree **list,
 {
 	struct worktree *wt;
 	char *path;
-	char *to_free;
+	char *to_free = NULL;
 
 	if ((wt = find_worktree_by_suffix(list, arg)))
 		return wt;
-- 
2.12.1-382-gc0f9c70589


  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21  1:18 [PATCH 0/6] prefix_filename cleanups Jeff King
2017-03-21  1:20 ` [PATCH 1/6] hash-object: fix buffer reuse with --path in a subdirectory Jeff King
2017-03-21  1:21 ` [PATCH 2/6] prefix_filename: move docstring to header file Jeff King
2017-03-21  1:22 ` [PATCH 3/6] prefix_filename: drop length parameter Jeff King
2017-03-21  1:28 ` [PATCH 4/6] prefix_filename: return newly allocated string Jeff King
2017-03-21 18:14   ` Junio C Hamano [this message]
2017-03-21 18:23     ` Jeff King
2017-03-21 23:32       ` Jeff King
2017-03-21  1:30 ` [PATCH 5/6] prefix_filename: simplify windows #ifdef Jeff King
2017-03-21  1:31 ` [PATCH 6/6] bundle: use prefix_filename with bundle path Jeff King
2017-03-21 17:53 ` [PATCH 0/6] prefix_filename cleanups Junio C Hamano

Reply instructions:

You may reply publically 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqinn2qyyo.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox