[PATCH 7/9] mv ":" ":" is like moving nothing from nowhere to nowhere
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 10, 2011, 05:51 UTC
- Message-ID
- <1305006678-4051-8-git-send-email-gitster@pobox.com>
- In-Reply-To
- <1305006678-4051-1-git-send-email-gitster@pobox.com>
Make sure the code can deal with get_pathspec() that returns nothing. Strictly speaking it may be a user error, but that is not an excuse to dump core.
Signed-off-by: Junio C Hamano <gitster@pobox.com> --- builtin/mv.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/builtin/mv.c b/builtin/mv.c index 93e8995..38af9f0 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -77,8 +77,12 @@ int cmd_mv(int argc, const char **argv, const char *prefix) die("index file corrupt"); source = copy_pathspec(prefix, argv, argc, 0); - modes = xcalloc(argc, sizeof(enum update_mode)); + if (!source) + die("copying from nowhere?"); + modes = xcalloc(count_pathspec(source), sizeof(enum update_mode)); dest_path = copy_pathspec(prefix, argv + argc, 1, 0); + if (!dest_path) + die("copying to nowhere?"); if (dest_path[0][0] == '\0') /* special case: "." was normalized to "" */
-- 1.7.5.1.290.g1b565