summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-09-04 10:29:28 -0700
committerJunio C Hamano <gitster@pobox.com>2015-09-04 10:29:28 -0700
commit8267cd11d677f1a5f8441ac2880f5e9d48dba60b (patch)
tree377d0d4141d50fbf44f68896a7e4f2e18ecd18ff /unpack-trees.c
parent9a3d637541a5b6fcd84b6f5fa057e597d1696460 (diff)
parent441c4a40173fe1ee8a5c0094e587dfc47e2a6460 (diff)
downloadgit-8267cd11d677f1a5f8441ac2880f5e9d48dba60b.tar.gz
Sync with 2.2.3
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index be84ba2607..17a5eeb6cd 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1434,15 +1434,18 @@ static int verify_absent_1(const struct cache_entry *ce,
if (!len)
return 0;
else if (len > 0) {
- char path[PATH_MAX + 1];
- memcpy(path, ce->name, len);
- path[len] = 0;
+ char *path;
+ int ret;
+
+ path = xmemdupz(ce->name, len);
if (lstat(path, &st))
- return error("cannot stat '%s': %s", path,
+ ret = error("cannot stat '%s': %s", path,
strerror(errno));
-
- return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
- error_type, o);
+ else
+ ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
+ &st, error_type, o);
+ free(path);
+ return ret;
} else if (lstat(ce->name, &st)) {
if (errno != ENOENT)
return error("cannot stat '%s': %s", ce->name,