From: <trast@student.ethz.ch>
To: Junio C Hamano <gitster@pobox.com>
Cc: <git@vger.kernel.org>, Pierre Habouzit <madcoder@debian.org>,
Thomas Rast <trast@student.ethz.ch>
Subject: [PATCH] Use memmove in ident_to_git
Date: Mon, 29 Aug 2011 22:06:04 +0200 [thread overview]
Message-ID: <c9efd696eb2361246b06008985013ebe68511f8d.1314648121.git.trast@student.ethz.ch> (raw)
From: Thomas Rast <trast@student.ethz.ch>
convert_to_git sets src=dst->buf if any of the preceding conversions
actually did any work. Thus in ident_to_git we have to use memmove
instead of memcpy as far as src->dst copying is concerned.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Valgrind intermittently detected this for me in t0021, hence the
patch. As far as I'm aware it has been broken since the rewrite to
memcpy back in 5ecd293 (Rewrite convert_to_{git,working_tree} to use
strbuf's., 2007-09-16). It probably never really mattered as all
involved copies are towards lower addresses (content is only removed)
and thus a straightforward memcpy operation will do the right thing by
accident.
convert.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/convert.c b/convert.c
index 416bf83..3bb5a4d 100644
--- a/convert.c
+++ b/convert.c
@@ -533,7 +533,7 @@ static int ident_to_git(const char *path, const char *src, size_t len,
dollar = memchr(src, '$', len);
if (!dollar)
break;
- memcpy(dst, src, dollar + 1 - src);
+ memmove(dst, src, dollar + 1 - src);
dst += dollar + 1 - src;
len -= dollar + 1 - src;
src = dollar + 1;
@@ -553,7 +553,7 @@ static int ident_to_git(const char *path, const char *src, size_t len,
src = dollar + 1;
}
}
- memcpy(dst, src, len);
+ memmove(dst, src, len);
strbuf_setlen(buf, dst + len - buf->buf);
return 1;
}
--
1.7.7.rc0.370.gdcae57
reply other threads:[~2011-08-29 20:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=c9efd696eb2361246b06008985013ebe68511f8d.1314648121.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madcoder@debian.org \
/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).