From 37871ce3f10c0db95d42d443c80dc7feb8ad6873 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 29 Aug 2005 15:10:02 +0000 Subject: [PATCH] Store the result of the A/W conversions in the extra buffer space. --- dlls/version/info.c | 35 +++++++++++------------------------ dlls/version/tests/info.c | 2 +- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/dlls/version/info.c b/dlls/version/info.c index 95665a83995..fac49bb0257 100644 --- a/dlls/version/info.c +++ b/dlls/version/info.c @@ -736,20 +736,13 @@ BOOL WINAPI VerQueryValueA( LPVOID pBlock, LPCSTR lpSubBlock, if (ret && strcasecmp( lpSubBlock, rootA ) && strcasecmp( lpSubBlock, varfileinfoA )) { - LPSTR lplpBufferA; + LPSTR lpBufferA = (LPSTR)pBlock + info->wLength + 4; + DWORD pos = (LPSTR)*lplpBuffer - (LPSTR)pBlock; - len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)*lplpBuffer, -1, NULL, 0, NULL, NULL); - lplpBufferA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char)); - - if (!lplpBufferA) - return FALSE; - - WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)*lplpBuffer, -1, lplpBufferA, len, NULL, NULL); - - memcpy(*lplpBuffer, lplpBufferA, len); + len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)*lplpBuffer, -1, + lpBufferA + pos, info->wLength - pos, NULL, NULL); + *lplpBuffer = lpBufferA + pos; *puLen = len; - - HeapFree(GetProcessHeap(), 0, lplpBufferA); } return ret; } @@ -792,20 +785,14 @@ BOOL WINAPI VerQueryValueW( LPVOID pBlock, LPCWSTR lpSubBlock, if (ret && strcmpiW( lpSubBlock, rootW ) && strcmpiW( lpSubBlock, varfileinfoW )) { - LPWSTR lplpBufferW; + LPWSTR lpBufferW = (LPWSTR)((LPSTR)pBlock + info->wLength); + DWORD pos = (LPSTR)*lplpBuffer - (LPSTR)pBlock; + DWORD max = (info->wLength - sizeof(VS_FIXEDFILEINFO)) * 4 - info->wLength; - len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*lplpBuffer, -1, NULL, 0); - lplpBufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - - if (!lplpBufferW) - return FALSE; - - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*lplpBuffer, -1, lplpBufferW, len); - - memcpy(*lplpBuffer, lplpBufferW, len * sizeof(WCHAR)); + len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*lplpBuffer, -1, + lpBufferW + pos, max/sizeof(WCHAR) - pos ); + *lplpBuffer = lpBufferW + pos; *puLen = len; - - HeapFree(GetProcessHeap(), 0, lplpBufferW); } return ret; } diff --git a/dlls/version/tests/info.c b/dlls/version/tests/info.c index fb241e2a5a0..4e40bfdfc16 100644 --- a/dlls/version/tests/info.c +++ b/dlls/version/tests/info.c @@ -391,7 +391,7 @@ static void test_32bit_win(void) /* Test a second time */ retA = VerQueryValueA( pVersionInfoA, FileDescriptionA, (LPVOID *)&pBufA, &uiLengthA ); ok (retA, "VerQueryValueA failed: GetLastError = 0x%08lx\n", GetLastError()); - todo_wine ok( !lstrcmpA(WineFileDescriptionA, pBufA), "FileDescription should have been 'Wine version test'\n"); + ok( !lstrcmpA(WineFileDescriptionA, pBufA), "FileDescription should have been 'Wine version test'\n"); if (is_unicode_enabled) {