From a478dda4d9b9794792a145166a63397c7769b3bb Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 7 Sep 2012 12:41:10 +0200 Subject: [PATCH] fflush(3) on fseeko(3). This caused a corruption of the resulting file if the program fwrite some data that is buffered, then fseeks, and then fflushes. The fwrite will then happen at the wrong memory location. Flushing in fseeko(3) fixes the problem but it may cause violate some standard or just be inefficient. --- libmaxsi/fseeko.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libmaxsi/fseeko.cpp b/libmaxsi/fseeko.cpp index 8341c583..b4de1757 100644 --- a/libmaxsi/fseeko.cpp +++ b/libmaxsi/fseeko.cpp @@ -27,5 +27,6 @@ extern "C" int fseeko(FILE* fp, off_t offset, int whence) { fp->numpushedback = 0; + fflush(fp); return (fp->seek_func) ? fp->seek_func(fp->user, offset, whence) : 0; }