Ilya Basin : shell32: Fix CommandLineToArgvW("") truncating returned exe path.
Alexandre Julliard
julliard at winehq.org
Mon Jul 26 13:22:40 CDT 2010
Module: wine
Branch: master
Commit: 9dee1b24eea47a8fc9dafdad4558bfe33e9ca0bb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9dee1b24eea47a8fc9dafdad4558bfe33e9ca0bb
Author: Ilya Basin <basinilya at gmail.com>
Date: Sat Jul 24 20:42:10 2010 +0400
shell32: Fix CommandLineToArgvW("") truncating returned exe path.
---
dlls/shell32/shell32_main.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index f906a24..a166150 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -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)
More information about the wine-cvs
mailing list