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.