Signed-off-by: Kun Yang yangkun@uniontech.com Change-Id: Ia68e11ccb0aa563eeb73a2f5cb93afcd328e1937
[fgetws_test.7z](/uploads/7b706f2c4f639e4260c548d834658b32/fgetws_test.7z) If the application calls setvbuf(.., _IONBF, ..) before fgetws, wine sets the flag. In fgetws, this flag is not checked. read_i is called with paramenter count 1 which is not allowed in read_i implemantion. Function read_i returns -1 and the file stream is not actually read by program. The file pointer is not moved. If the application writes fgetws in a loop, it never reach EOF and falls in dead loop. By adding check for _IONBF in _filbuf, the application will run into another branch(file->_bufsiz=2). Thats's correct. Please checkout the example in my attachment. This application exits normally in Windows but falls in dead loop in wine.
-- v3: msvcrt: Add MSVCRT__NOBUF flag check in _filbuf to avoid dead loop in application which sets the flag.
From: Kun Yang yangkun@uniontech.com
Signed-off-by: Kun Yang yangkun@uniontech.com Change-Id: Ia68e11ccb0aa563eeb73a2f5cb93afcd328e1937 --- dlls/msvcrt/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index dda12a70194..98df53be77d 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -3834,7 +3834,7 @@ int CDECL _filbuf(FILE* file) return EOF; }
- if(!(file->_flag & (_IOMYBUF | MSVCRT__USERBUF))) { + if(!(file->_flag & (MSVCRT__NOBUF | _IOMYBUF | MSVCRT__USERBUF))) { int r; if ((r = _read(file->_file,&c,1)) != 1) { file->_flag |= (r == 0) ? _IOEOF : _IOERR;
This merge request was approved by Piotr Caban.