Store the result of the A/W conversions in the extra buffer space.

This commit is contained in:
Alexandre Julliard 2005-08-29 15:10:02 +00:00
parent 31d0e7421e
commit 37871ce3f1
2 changed files with 12 additions and 25 deletions

View File

@ -736,20 +736,13 @@ BOOL WINAPI VerQueryValueA( LPVOID pBlock, LPCSTR lpSubBlock,
if (ret && strcasecmp( lpSubBlock, rootA ) && strcasecmp( lpSubBlock, varfileinfoA )) 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); len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)*lplpBuffer, -1,
lplpBufferA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char)); lpBufferA + pos, info->wLength - pos, NULL, NULL);
*lplpBuffer = lpBufferA + pos;
if (!lplpBufferA)
return FALSE;
WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)*lplpBuffer, -1, lplpBufferA, len, NULL, NULL);
memcpy(*lplpBuffer, lplpBufferA, len);
*puLen = len; *puLen = len;
HeapFree(GetProcessHeap(), 0, lplpBufferA);
} }
return ret; return ret;
} }
@ -792,20 +785,14 @@ BOOL WINAPI VerQueryValueW( LPVOID pBlock, LPCWSTR lpSubBlock,
if (ret && strcmpiW( lpSubBlock, rootW ) && strcmpiW( lpSubBlock, varfileinfoW )) 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); len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*lplpBuffer, -1,
lplpBufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); lpBufferW + pos, max/sizeof(WCHAR) - pos );
*lplpBuffer = lpBufferW + pos;
if (!lplpBufferW)
return FALSE;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*lplpBuffer, -1, lplpBufferW, len);
memcpy(*lplpBuffer, lplpBufferW, len * sizeof(WCHAR));
*puLen = len; *puLen = len;
HeapFree(GetProcessHeap(), 0, lplpBufferW);
} }
return ret; return ret;
} }

View File

@ -391,7 +391,7 @@ static void test_32bit_win(void)
/* Test a second time */ /* Test a second time */
retA = VerQueryValueA( pVersionInfoA, FileDescriptionA, (LPVOID *)&pBufA, &uiLengthA ); retA = VerQueryValueA( pVersionInfoA, FileDescriptionA, (LPVOID *)&pBufA, &uiLengthA );
ok (retA, "VerQueryValueA failed: GetLastError = 0x%08lx\n", GetLastError()); 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) if (is_unicode_enabled)
{ {