Skip to content

Commit

Permalink
builtin/mv.c: plug miniscule memory leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brandon Casey authored and Junio C Hamano committed Oct 6, 2011
1 parent 040a655 commit 0d0ff65
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion builtin/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0d0ff65

Please sign in to comment.