Anonymous committed d551bba

fetch-pack: Avoid memcpy() with src==dst

memcpy() may only be used for disjoint memory areas, but when invoked
from cmd_fetch_pack(), we have my_args == &args. (The argument cannot
be removed entirely because transport.c invokes with its own

Signed-off-by: Thomas Rast <>
Signed-off-by: Junio C Hamano <>

  • Participants
  • Parent commits 2ab4de5

Comments (0)

Files changed (1)

File builtin-fetch-pack.c

 	struct ref *ref_cpy;
-	memcpy(&args, my_args, sizeof(args));
+	if (&args != my_args)
+		memcpy(&args, my_args, sizeof(args));
 	if (args.depth > 0) {
 		if (stat(git_path("shallow"), &st))
 			st.st_mtime = 0;