From: Brandon Casey Date: Thu, 6 Oct 2011 18:22:23 +0000 (-0500) Subject: builtin/mv.c: plug miniscule memory leak X-Git-Tag: v1.7.8-rc0~54^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0d0ff65cea5424a202510fa4e28a461d36032276;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/mv.c b/builtin/mv.c index e9d191f05..5efe6c576 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);