@matheusbsbs / matheus-bagliano / commits / b5041c5f3b
Fork 0

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>

Nguyễn Thái Ngọc Duy committed Aug 20, 2009 at 20:47 UTC b5041c5f3b9ea70ce7aa9711af6ed6f2d02909b0
1 file changed +2 -3
dir.c
+2 -3
@@ -229,10 +229,9 @@ static int add_excludes_from_file_1(const char *fname,
229
230 if (buf_p)
231 *buf_p = buf;
232 - buf[size++] = '\n';
232 entry = buf;
234 - for (i = 0; i < size; i++) {
235 - if (buf[i] == '\n') {
233 + for (i = 0; i <= size; i++) {
234 + if (i == size || buf[i] == '\n') {
235 if (entry != buf + i && entry[0] != '#') {
236 buf[i - (i && buf[i-1] == '\r')] = 0;
237 add_exclude(entry, base, baselen, which);