aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-12-26 12:34:56 -0800
committerJunio C Hamano <junkio@cox.net>2005-12-26 17:23:59 -0800
commit7e4a2a848377241b8fb4f624d1151bbf2f8d5814 (patch)
tree5b7f555c6aebd9c32b97dc27f3a18723549415f3 /diff.c
parent7d6fb370bc98e5d4723103dda0829b00c79da213 (diff)
downloadgit-7e4a2a848377241b8fb4f624d1151bbf2f8d5814.tar.gz
git-7e4a2a848377241b8fb4f624d1151bbf2f8d5814.tar.xz
avoid asking ?alloc() for zero bytes.
Avoid asking for zero bytes when that change simplifies overall logic. Later we would change the wrapper to ask for 1 byte on platforms that return NULL for zero byte request. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index c8159183d..bfc864d9c 100644
--- a/diff.c
+++ b/diff.c
@@ -504,9 +504,9 @@ static void prepare_temp_file(const char *name,
}
if (S_ISLNK(st.st_mode)) {
int ret;
- char *buf, buf_[1024];
- buf = ((sizeof(buf_) < st.st_size) ?
- xmalloc(st.st_size) : buf_);
+ char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */
+ if (sizeof(buf) <= st.st_size)
+ die("symlink too long: %s", name);
ret = readlink(name, buf, st.st_size);
if (ret < 0)
die("readlink(%s)", name);