summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-09-09 21:30:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-09-09 21:30:35 (GMT)
commitf0bc85462332644ecd2386e0f4fdc9948b9f47dc (patch)
tree6ee0f442ec888c33a25e825a4e451b921c0701ff /unpack-trees.c
parent7a2c4af7a82eebf2ed0e60a2b36c31e70c619264 (diff)
parent27ea6f85beff1173ec74349fa35c45951feee570 (diff)
downloadgit-f0bc85462332644ecd2386e0f4fdc9948b9f47dc.zip
git-f0bc85462332644ecd2386e0f4fdc9948b9f47dc.tar.gz
git-f0bc85462332644ecd2386e0f4fdc9948b9f47dc.tar.bz2
Sync with 2.5.2
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 bb09b1e..f932e80 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1451,15 +1451,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,