Skip to content

Commit 3de73a9

Browse files
committed
Fix AWFUL BUG in last commit. Beofre calling fstat one *MUST* use fflush to flush
the stdio stream *BEFORE* calling fstat because otherwise a bad size may be answered. For those of you who have made a VM in the last 24 hours PLEASE DISCARD IT AND REBUILD. THAT VM CAN CORRUPT YOUR CHANGES FILE!!
1 parent 283871f commit 3de73a9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ getSize(SQFile *f)
133133
# if !defined(NO_STD_FILE_SUPPORT)
134134
struct stat buf;
135135

136+
// If using fstat it is vital to ensure all output has been written before accessing the size.
137+
// An fflush is implicit in the fseeko calls that follow.
138+
fflush(file);
136139
if (!fstat(fileno(file),&buf))
137140
return buf.st_size;
138141
#endif

0 commit comments

Comments
 (0)