Skip to content

Commit

Permalink
Avoid writing to buffer in add_excludes_from_file_1()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 24, 2009
1 parent 5203083 commit b5041c5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b5041c5

Please sign in to comment.