Commit 9dee1b24 authored by Ilya Basin's avatar Ilya Basin Committed by Alexandre Julliard

shell32: Fix CommandLineToArgvW("") truncating returned exe path.

parent f6299c1b
......@@ -94,20 +94,22 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
if (*lpCmdline==0)
{
/* Return the path to the executable */
DWORD len, size=16;
DWORD len, deslen=MAX_PATH, size;
argv=LocalAlloc(LMEM_FIXED, size);
size = sizeof(LPWSTR) + deslen*sizeof(WCHAR) + sizeof(LPWSTR);
for (;;)
{
len = GetModuleFileNameW(0, (LPWSTR)(argv+1), (size-sizeof(LPWSTR))/sizeof(WCHAR));
if (!(argv = LocalAlloc(LMEM_FIXED, size))) return NULL;
len = GetModuleFileNameW(0, (LPWSTR)(argv+1), deslen);
if (!len)
{
LocalFree(argv);
return NULL;
}
if (len < size) break;
size*=2;
argv=LocalReAlloc(argv, size, 0);
if (len < deslen) break;
deslen*=2;
size = sizeof(LPWSTR) + deslen*sizeof(WCHAR) + sizeof(LPWSTR);
LocalFree( argv );
}
argv[0]=(LPWSTR)(argv+1);
if (numargs)
......
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