From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/msvcrt/file.c | 4 +--- dlls/msvcrt/tests/file.c | 10 ++-------- 2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index e72784eef41..24d801a5306 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -4588,9 +4588,7 @@ FILE* CDECL _wfreopen(const wchar_t *path, const wchar_t *mode, FILE* file) TRACE(":path (%s) mode (%s) file (%p) fd (%d)\n", debugstr_w(path), debugstr_w(mode), file, file ? file->_file : -1);
LOCK_FILES(); - if (!file || ((fd = file->_file) < 0)) - file = NULL; - else + if (file) { fclose(file); if (msvcrt_get_flags(mode, &open_flags, &stream_flags) == -1) diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 106c1554518..4c62a890459 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1237,20 +1237,15 @@ static void test_freopen( void ) file->_file = -1;
new = freopen(filename2, "rb", file); - todo_wine ok(new == file, "freopen() didn't return same FILE*\n"); - if (new) { /* temporary as it crashes on wine */
- fd = fileno(new); - todo_wine + fd = fileno(file); ok(fd > 0, "fileno() returned %d\n", fd);
errno = 0xdeadbeef; ch = '#'; - ret = fread(&ch, 1, 1, new); - todo_wine + ret = fread(&ch, 1, 1, file); ok(ret == 1, "fread() returned %d\n", ret); - todo_wine ok(errno == 0xdeadbeef, "errno = %d\n", errno); ok(ch == '2', "Unexpected char\n");
@@ -1259,7 +1254,6 @@ static void test_freopen( void ) ok(new == NULL, "Shouldn't be able to reopen FILE\n");
/* don't close file, it's invalid by now */ - }
unlink(filename1); unlink(filename2);