Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2011-10-06 22:22:23 +0400
committerJunio C Hamano <gitster@pobox.com>2011-10-07 00:54:32 +0400
commit0d0ff65cea5424a202510fa4e28a461d36032276 (patch)
tree86f4aee1bddefc29d904f176c59a2cc0b4bf03cd /builtin/mv.c
parent040a655116c9755bbf30acd22c34eecb2f502c6d (diff)
builtin/mv.c: plug miniscule memory leak
The "it" string would not be free'ed if base_name was non-NULL. Let's free it. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/mv.c')
-rw-r--r--builtin/mv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/mv.c b/builtin/mv.c
index e9d191f056..5efe6c5760 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -29,7 +29,11 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
to_copy--;
if (to_copy != length || base_name) {
char *it = xmemdupz(result[i], to_copy);
- result[i] = base_name ? xstrdup(basename(it)) : it;
+ if (base_name) {
+ result[i] = xstrdup(basename(it));
+ free(it);
+ } else
+ result[i] = it;
}
}
return get_pathspec(prefix, result);