Piotr Caban : msvcrt: Use fd critical section in _chsize_s.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Dec 5 15:36:55 CST 2014
Module: wine
Branch: master
Commit: f2f45d5fe67cd8e4129e5ec409fde10fb62b87bd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f2f45d5fe67cd8e4129e5ec409fde10fb62b87bd
Author: Piotr Caban <piotr at codeweavers.com>
Date: Fri Dec 5 14:43:07 2014 +0100
msvcrt: Use fd critical section in _chsize_s.
---
dlls/msvcrt/file.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 174ec64..3eae1f1 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -1377,18 +1377,17 @@ int CDECL MSVCRT__fseek_nolock(MSVCRT_FILE* file, MSVCRT_long offset, int whence
*/
int CDECL MSVCRT__chsize_s(int fd, __int64 size)
{
+ ioinfo *info;
__int64 cur, pos;
- HANDLE handle;
BOOL ret = FALSE;
TRACE("(fd=%d, size=%s)\n", fd, wine_dbgstr_longlong(size));
if (!MSVCRT_CHECK_PMT(size >= 0)) return MSVCRT_EINVAL;
- LOCK_FILES();
- handle = msvcrt_fdtoh(fd);
- if (handle != INVALID_HANDLE_VALUE)
+ info = get_ioinfo(fd);
+ if (info->handle != INVALID_HANDLE_VALUE)
{
/* save the current file pointer */
cur = MSVCRT__lseeki64(fd, 0, SEEK_CUR);
@@ -1397,7 +1396,7 @@ int CDECL MSVCRT__chsize_s(int fd, __int64 size)
pos = MSVCRT__lseeki64(fd, size, SEEK_SET);
if (pos >= 0)
{
- ret = SetEndOfFile(handle);
+ ret = SetEndOfFile(info->handle);
if (!ret) msvcrt_set_errno(GetLastError());
}
@@ -1406,7 +1405,7 @@ int CDECL MSVCRT__chsize_s(int fd, __int64 size)
}
}
- UNLOCK_FILES();
+ release_ioinfo(info);
return ret ? 0 : *MSVCRT__errno();
}
More information about the wine-cvs
mailing list