1
0
mirror of https://github.com/git/git.git synced 2024-09-28 20:51:42 +02:00

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>
This commit is contained in:
Brandon Casey 2011-10-06 13:22:23 -05:00 committed by Junio C Hamano
parent 040a655116
commit 0d0ff65cea

@ -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);