From: Junio C Hamano Date: Thu, 20 Aug 2015 16:57:32 +0000 (-0700) Subject: ps_matched: xcalloc() takes nmemb and then element size X-Git-Tag: v2.6.0-rc0~35^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8b54c23437834b36bbb5f6de2f577400385da770;p=git-core%2Fgit.git ps_matched: xcalloc() takes nmemb and then element size Even though multiplication is commutative, the order of arguments should be xcalloc(nmemb, size). ps_matched is an array of 1-byte element whose size is the same as the number of pathspec elements. Signed-off-by: Junio C Hamano --- diff --git a/builtin/checkout.c b/builtin/checkout.c index 3e141fc14..4f826e3b0 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -280,7 +280,7 @@ static int checkout_paths(const struct checkout_opts *opts, if (opts->source_tree) read_tree_some(opts->source_tree, &opts->pathspec); - ps_matched = xcalloc(1, opts->pathspec.nr); + ps_matched = xcalloc(opts->pathspec.nr, 1); /* * Make sure all pathspecs participated in locating the paths diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 6fa220573..b6a7cb0c7 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -516,7 +516,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) /* Treat unmatching pathspec elements as errors */ if (pathspec.nr && error_unmatch) - ps_matched = xcalloc(1, pathspec.nr); + ps_matched = xcalloc(pathspec.nr, 1); if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given) die("ls-files --ignored needs some exclude pattern");