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>
This commit is contained in:
parent
5203083694
commit
b5041c5f3b
5
dir.c
5
dir.c
@ -229,10 +229,9 @@ static int add_excludes_from_file_1(const char *fname,
|
|||||||
|
|
||||||
if (buf_p)
|
if (buf_p)
|
||||||
*buf_p = buf;
|
*buf_p = buf;
|
||||||
buf[size++] = '\n';
|
|
||||||
entry = buf;
|
entry = buf;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i <= size; i++) {
|
||||||
if (buf[i] == '\n') {
|
if (i == size || buf[i] == '\n') {
|
||||||
if (entry != buf + i && entry[0] != '#') {
|
if (entry != buf + i && entry[0] != '#') {
|
||||||
buf[i - (i && buf[i-1] == '\r')] = 0;
|
buf[i - (i && buf[i-1] == '\r')] = 0;
|
||||||
add_exclude(entry, base, baselen, which);
|
add_exclude(entry, base, baselen, which);
|
||||||
|
Loading…
Reference in New Issue
Block a user