summaryrefslogtreecommitdiff
path: root/builtin/update-index.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-05-11 14:23:57 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-05-11 14:23:58 -0700
commitb9f5d3874f3406c820049b26fd7b10f7cae7138f (patch)
tree9e04ad12af0bbb6facb0068939d095b21e88d6f8 /builtin/update-index.c
parentMerge branch 'sg/completion-no-redundant-all-command-list' (diff)
parentprefix_path(): unconditionally free results in the callers (diff)
downloadtgif-b9f5d3874f3406c820049b26fd7b10f7cae7138f.tar.xz
Merge branch 'sb/prefix-path-free-results'
Code clean-up (not a leak-fix). * sb/prefix-path-free-results: prefix_path(): unconditionally free results in the callers
Diffstat (limited to 'builtin/update-index.c')
-rw-r--r--builtin/update-index.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 6271b54adc..0665b31ea1 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -532,10 +532,9 @@ static int do_unresolve(int ac, const char **av,
for (i = 1; i < ac; i++) {
const char *arg = av[i];
- const char *p = prefix_path(prefix, prefix_length, arg);
+ char *p = prefix_path(prefix, prefix_length, arg);
err |= unresolve_one(p);
- if (p < arg || p > arg + strlen(arg))
- free((char *)p);
+ free(p);
}
return err;
}
@@ -871,14 +870,14 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
case PARSE_OPT_DONE:
{
const char *path = ctx.argv[0];
- const char *p;
+ char *p;
setup_work_tree();
p = prefix_path(prefix, prefix_length, path);
update_one(p);
if (set_executable_bit)
chmod_path(set_executable_bit, p);
- free((char *)p);
+ free(p);
ctx.argc--;
ctx.argv++;
break;
@@ -909,7 +908,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
setup_work_tree();
while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
- const char *p;
+ char *p;
if (line_termination && buf.buf[0] == '"') {
strbuf_reset(&nbuf);
if (unquote_c_style(&nbuf, buf.buf, NULL))
@@ -920,7 +919,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
update_one(p);
if (set_executable_bit)
chmod_path(set_executable_bit, p);
- free((char *)p);
+ free(p);
}
strbuf_release(&nbuf);
strbuf_release(&buf);