Commit 9f7bc109 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Avoid returning the same name when GetTempFileName is called twice in a short interval.

parent 7649c75b
......@@ -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 &&
......
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