shithub: mc

Download patch

ref: 0fe13a1edf5cdfcd5080df42795dc4ec0204f68e
parent: 19a2bf91cafd9c3e58a30f815a13e8d05a2359ca
author: Ori Bernstein <[email protected]>
date: Wed May 14 21:43:43 EDT 2014

flush on a file without write shouldn't write.

    This caused a problem where we were trying to write to invalid
    files.

--- a/bio.myr
+++ b/bio.myr
@@ -201,8 +201,11 @@
 const flush = {f
 	var ret
 
-	ret = (writebuf(f.fd, f.wbuf[:f.wend]) == f.wend)
-	f.wend = 0
+	ret = true
+	if f.mode & Wr != 0
+		ret = (writebuf(f.fd, f.wbuf[:f.wend]) == f.wend)
+		f.wend = 0
+	;;
 	-> ret
 }