From 6e49be9af735766630fd7b2fdb646127b126c873 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 12 Oct 2011 17:43:33 +0200 Subject: [PATCH] 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. --- book.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) 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; -- 1.7.0.4