Alexandre Julliard : kernel32: Avoid returning the same name when GetTempFileName is called twice in a short interval .
Alexandre Julliard
julliard at winehq.org
Thu Jun 24 11:15:23 CDT 2010
Module: wine
Branch: master
Commit: 9f7bc109d20a07367875fcd6044dbaad41d9eb7e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9f7bc109d20a07367875fcd6044dbaad41d9eb7e
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jun 24 11:01:56 2010 +0200
kernel32: Avoid returning the same name when GetTempFileName is called twice in a short interval.
---
dlls/kernel32/path.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index f0da96c..0e69f91 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -684,7 +684,10 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, LPWSTR
/* get a "random" unique number and try to create the file */
HANDLE handle;
UINT num = GetTickCount() & 0xffff;
+ static UINT last;
+ /* avoid using the same name twice in a short interval */
+ if (last - num < 10) num = last + 1;
if (!num) num = 1;
unique = num;
do
@@ -696,6 +699,7 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, LPWSTR
{ /* We created it */
TRACE("created %s\n", debugstr_w(buffer) );
CloseHandle( handle );
+ last = unique;
break;
}
if (GetLastError() != ERROR_FILE_EXISTS &&
More information about the wine-cvs
mailing list