http://bugs.winehq.org/show_bug.cgi?id=17123
--- Comment #3 from Juan Lang juan_lang@yahoo.com 2009-01-26 11:06:23 --- (In reply to comment #2)
Created an attachment (id=18973)
--> (http://bugs.winehq.org/attachment.cgi?id=18973) [details]
A patch and test case which sets in _flsbuf the file->_cnt to 0
This looks reasonable, even though it is working around a MinGW bug ;-) Could you send to wine-patches, or if you're not sure about it, solicit feedback on wine-devel? Patches aren't picked up here.
I'm not sure when exactly to set flag->_cnt to 0.
It looks as though it's set to 0 whenever there's no buffered output, so your patch looks correct in this respect.
(Also is in MSVCRT_fwrite memcpy(file->_ptr, ptr, pcnt); is there check needed if file->_ptr is a valid pointer?)
I don't think so. From reading file.c, it seems as though it's assumed that file->_ptr must be valid if file->_cnt is non-zero.