From fb8a4e8079ab8fc37e9cde32957c35637280ab8f Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 15 Mar 2014 18:56:52 +0000 Subject: mv: prevent mismatched data when ignoring errors. We shrink the source and destination arrays, but not the modes or submodule_gitfile arrays, resulting in potentially mismatched data. Shrink all the arrays at the same time to prevent this. Add tests to ensure the problem does not recur. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- builtin/mv.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtin/mv.c') diff --git a/builtin/mv.c b/builtin/mv.c index 525807722..45e57f307 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -231,6 +231,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix) memmove(destination + i, destination + i + 1, (argc - i) * sizeof(char *)); + memmove(modes + i, modes + i + 1, + (argc - i) * sizeof(enum update_mode)); + memmove(submodule_gitfile + i, + submodule_gitfile + i + 1, + (argc - i) * sizeof(char *)); i--; } } else -- cgit v1.2.1