From 79bc9ccf8ea5606da2a86e1bfb5439e73a146272 Mon Sep 17 00:00:00 2001 From: whatdoineed2do Date: Thu, 25 Jul 2019 03:57:49 +0100 Subject: Call fflush() before ftruncate() to drop all buffered data (#914) This avoids stale data presented to caller via a fread() Current bug due to the buffered data can be seen in stripping mp3s of tags f.strip(ID3v1); f.strip(APE); The ID3v1 tag sits at the end of file (strip calls ftruncate()) and the APE strip performs a readFile() that would return the stream buffered/truncated data and reinsert --- taglib/toolkit/tfilestream.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 487df8e3..20e1dfbc 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -493,6 +493,7 @@ void FileStream::truncate(long length) #else + fflush(d->file); const int error = ftruncate(fileno(d->file), length); if(error != 0) debug("FileStream::truncate() -- Coundn't truncate the file."); -- cgit v1.2.3