summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-08-20 20:47:00 +0700
committerJunio C Hamano <gitster@pobox.com>2009-08-23 17:13:32 -0700
commitb5041c5f3b9ea70ce7aa9711af6ed6f2d02909b0 (patch)
treee3a16c42f315fa8d714a08e2e59dae7e26fa7415 /dir.c
parent52030836943c0d28d8be4202762ede28e921dc21 (diff)
downloadgit-b5041c5f3b9ea70ce7aa9711af6ed6f2d02909b0.tar.gz
Avoid writing to buffer in add_excludes_from_file_1()
In the next patch, the buffer that is being used within add_excludes_from_file_1() comes from another function and does not have extra space to put \n at the end. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/dir.c b/dir.c
index e05b850acf..1170d64675 100644
--- a/dir.c
+++ b/dir.c
@@ -229,10 +229,9 @@ static int add_excludes_from_file_1(const char *fname,
if (buf_p)
*buf_p = buf;
- buf[size++] = '\n';
entry = buf;
- for (i = 0; i < size; i++) {
- if (buf[i] == '\n') {
+ for (i = 0; i <= size; i++) {
+ if (i == size || buf[i] == '\n') {
if (entry != buf + i && entry[0] != '#') {
buf[i - (i && buf[i-1] == '\r')] = 0;
add_exclude(entry, base, baselen, which);