Skip to content
Snippets Groups Projects
Commit 2f5e5f3d authored by Adam Gundy's avatar Adam Gundy Committed by Alexandre Julliard
Browse files

MSVCRT_fclose() mustn't use the _flag field from the file structure

after _close() has been called.
When _open_osfhandle() is used by MFC's CStdioFile, it expects write
access even though it doesn't set the necessary flag bit.
parent da9720c7
No related branches found
No related tags found
No related merge requests found
......@@ -1124,10 +1124,13 @@ int _wcreat(const MSVCRT_wchar_t *path, int flags)
*/
int _open_osfhandle(long hand, int flags)
{
/* _O_RDONLY (0) always matches, so set the read flag*/
/* _O_RDONLY (0) always matches, so set the read flag
* MFC's CStdioFile clears O_RDONLY (0)! if it wants to write to the
* file, so set the write flag
*/
/* FIXME: handle more flags */
int fd= msvcrt_alloc_fd((HANDLE)hand,flags|MSVCRT__IOREAD);
TRACE(":handle (%ld) fd (%d) flags 0x%08x\n",hand,fd, flags |MSVCRT__IOREAD);
int fd= msvcrt_alloc_fd((HANDLE)hand,flags|MSVCRT__IOREAD|MSVCRT__IOWRT);
TRACE(":handle (%ld) fd (%d) flags 0x%08x\n",hand,fd, flags |MSVCRT__IOREAD|MSVCRT__IOWRT);
return fd;
}
......@@ -1556,9 +1559,11 @@ void MSVCRT_clearerr(MSVCRT_FILE* file)
*/
int MSVCRT_fclose(MSVCRT_FILE* file)
{
int r;
int r, flag;
flag = file->_flag;
r=_close(file->_file);
return ((r==MSVCRT_EOF) || (file->_flag & MSVCRT__IOERR) ? MSVCRT_EOF : 0);
return ((r==MSVCRT_EOF) || (flag & MSVCRT__IOERR) ? MSVCRT_EOF : 0);
}
/*********************************************************************
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment