DORMANTno replies

[PATCH] Use memmove in ident_to_git

From: <hidden>
Date: 2016-06-15 22:51:56
Subsystem: the rest · Maintainer: Linus Torvalds

From: Thomas Rast <redacted>

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 <redacted>
---

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help