aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwhatdoineed2do <whatdoineed2do@gmail.com>2019-07-25 03:57:49 +0100
committerStephen F. Booth <me@sbooth.org>2019-07-25 07:27:49 +0430
commit79bc9ccf8ea5606da2a86e1bfb5439e73a146272 (patch)
tree80cfb9b03d2ad747c4263f561ca858051d2adbf6
parentba7adc2bc261ed634c2a964185bcffb9365ad2f4 (diff)
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
-rw-r--r--taglib/toolkit/tfilestream.cpp1
1 files changed, 1 insertions, 0 deletions
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.");