Commit 96584d85 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Don't report error in fclose on already closed stream.

parent 1899eadf
......@@ -3627,6 +3627,12 @@ int CDECL MSVCRT__fclose_nolock(MSVCRT_FILE* file)
{
int r, flag;
if(!(file->_flag & (MSVCRT__IOREAD | MSVCRT__IOWRT | MSVCRT__IORW)))
{
file->_flag = 0;
return MSVCRT_EOF;
}
flag = file->_flag;
MSVCRT_free(file->_tmpfname);
file->_tmpfname = NULL;
......
......@@ -1742,10 +1742,13 @@ static void test_fopen_fclose_fcloseall( void )
ok(ret == 0, "The file '%s' was not closed\n", fname2);
ret = fclose(stream3);
ok(ret == 0, "The file '%s' was not closed\n", fname3);
errno = 0xdeadbeef;
ret = fclose(stream2);
ok(ret == EOF, "Closing file '%s' returned %d\n", fname2, ret);
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
ret = fclose(stream3);
ok(ret == EOF, "Closing file '%s' returned %d\n", fname3, ret);
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
/* testing fcloseall() */
numclosed = _fcloseall();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment