From: Junio C Hamano <gitster@pobox.com>
To: "Carlos Martín Nieto" <cmn@elego.de>
Cc: git@vger.kernel.org, Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Subject: Re: [PATCH 1/3] make_absolute_path: return the input path if it points to our buffer
Date: Wed, 16 Mar 2011 13:51:13 -0700 [thread overview]
Message-ID: <7vaagu7pry.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1300291579-25852-2-git-send-email-cmn@elego.de> ("Carlos Martín Nieto"'s message of "Wed, 16 Mar 2011 17:06:17 +0100")
Carlos Martín Nieto <cmn@elego.de> writes:
> Some codepaths call make_absolute_path with its own return value as
> input. In such a cases, return the path immediately.
>
> This fixes a valgrind-discovered error, whereby we tried to copy a
> string onto itself.
>
> Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
> ---
> abspath.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/abspath.c b/abspath.c
> index 91ca00f..ff14068 100644
> --- a/abspath.c
> +++ b/abspath.c
> @@ -24,6 +24,10 @@ const char *make_absolute_path(const char *path)
> char *last_elem = NULL;
> struct stat st;
>
> + /* We've already done it */
> + if (path == buf || path == next_buf)
> + return path;
> +
I like this, as it is very obvious what we are checking here. Thanks.
next prev parent reply other threads:[~2011-03-16 20:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 16:06 [PATCH 0/3] Rename make_*_path with clearer names Carlos Martín Nieto
2011-03-16 16:06 ` [PATCH 1/3] make_absolute_path: return the input path if it points to our buffer Carlos Martín Nieto
2011-03-16 20:51 ` Junio C Hamano [this message]
2011-03-16 16:06 ` [PATCH 2/3] Name make_*_path functions more accurately Carlos Martín Nieto
2011-03-16 16:29 ` Brian Gernhardt
2011-03-16 16:42 ` Carlos Martín Nieto
2011-03-16 16:06 ` [PATCH 3/3] Use the new {real,absolute}_path function names Carlos Martín Nieto
2011-03-16 16:24 ` Erik Faye-Lund
2011-03-16 16:37 ` Carlos Martín Nieto
2011-03-16 16:52 ` [PATCH 2-3/3] Name make_*_path functions more accurately Carlos Martín Nieto
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=7vaagu7pry.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=cmn@elego.de \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.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).