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>
Brandon Casey committed
Oct 6, 2011 at 13:22 UTC
0d0ff65cea5424a202510fa4e28a461d36032276
1 file changed
+5
-1
builtin/mv.c
+5
-1
@@ -29,7 +29,11 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
29
to_copy--;
30
if (to_copy != length || base_name) {
31
char *it = xmemdupz(result[i], to_copy);
32
- result[i] = base_name ? xstrdup(basename(it)) : it;
32
+ if (base_name) {
33
+ result[i] = xstrdup(basename(it));
34
+ free(it);
35
+ } else
36
+ result[i] = it;
37
}
38
}
39
return get_pathspec(prefix, result);