From: H.G. Muller Date: Wed, 12 Oct 2011 15:43:33 +0000 (+0200) Subject: Fix crash on adding items near book end X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=6e49be9af735766630fd7b2fdb646127b126c873;p=xboard.git Fix crash on adding items near book end When Edit Book would add so many entries near the end of an opening book that the end of the added info would surpass the old end of the file, the copying of the tail got stuck in an infinite loop, extending the file without limit with repeating info. --- diff --git a/book.c b/book.c index e42b9c6..6b1198d 100644 --- a/book.c +++ b/book.c @@ -676,8 +676,10 @@ void SaveToBook(char *text) if(count != currentCount) { do { for(i=0; i writepos) { + fseek(f, readpos, SEEK_SET); + readpos += len1 = fread(buf1, 1, 4096, f); + } else len1 = 0; // wrote already past old EOF fseek(f, writepos, SEEK_SET); fwrite(buf2, 1, len2, f); writepos += len2;