msi: Return the string length even if the string is NULL.

This commit is contained in:
James Hawkins 2008-02-04 11:37:19 -06:00 committed by Alexandre Julliard
parent 40841946f5
commit dc8f714ade
2 changed files with 12 additions and 17 deletions

View File

@ -1611,7 +1611,8 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
ret = GetLastError(); ret = GetLastError();
goto end; goto end;
} }
if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
if (pcchVersionBuf)
{ {
if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) && if( VerQueryValueW(lpVer, szVersionResource, (LPVOID*)&ffi, &puLen) &&
(puLen > 0) ) (puLen > 0) )
@ -1619,24 +1620,24 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
wsprintfW(tmp, szVersionFormat, wsprintfW(tmp, szVersionFormat,
HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS)); HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf); if (lpVersionBuf) lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
*pcchVersionBuf = lstrlenW(lpVersionBuf); *pcchVersionBuf = lstrlenW(tmp);
} }
else else
{ {
*lpVersionBuf = 0; if (lpVersionBuf) *lpVersionBuf = 0;
*pcchVersionBuf = 0; *pcchVersionBuf = 0;
} }
} }
if( lpLangBuf && pcchLangBuf && *pcchLangBuf ) if (pcchLangBuf)
{ {
DWORD lang = GetUserDefaultLangID(); DWORD lang = GetUserDefaultLangID();
FIXME("Retrieve language from file\n"); FIXME("Retrieve language from file\n");
wsprintfW(tmp, szLangFormat, lang); wsprintfW(tmp, szLangFormat, lang);
lstrcpynW(lpLangBuf, tmp, *pcchLangBuf); if (lpLangBuf) lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
*pcchLangBuf = lstrlenW(lpLangBuf); *pcchLangBuf = lstrlenW(tmp);
} }
end: end:

View File

@ -2012,19 +2012,13 @@ static void test_MsiGetFileVersion(void)
versz = MAX_PATH; versz = MAX_PATH;
r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL); r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
{
ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
}
/* get pcchLangBuf */ /* get pcchLangBuf */
langsz = MAX_PATH; langsz = MAX_PATH;
r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz); r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
{
ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
}
/* pcchVersionBuf not big enough */ /* pcchVersionBuf not big enough */
versz = 5; versz = 5;
@ -2032,10 +2026,10 @@ static void test_MsiGetFileVersion(void)
r = MsiGetFileVersionA(path, version, &versz, NULL, NULL); r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
ok(!strncmp(version, vercheck, 4), ok(!strncmp(version, vercheck, 4),
"Expected first 4 characters of %s, got %s\n", vercheck, version); "Expected first 4 characters of %s, got %s\n", vercheck, version);
ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
todo_wine todo_wine
{ {
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r); ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
} }
/* pcchLangBuf not big enough */ /* pcchLangBuf not big enough */
@ -2044,10 +2038,10 @@ static void test_MsiGetFileVersion(void)
r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz); r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
ok(!strncmp(lang, langcheck, 2), ok(!strncmp(lang, langcheck, 2),
"Expected first character of %s, got %s\n", langcheck, lang); "Expected first character of %s, got %s\n", langcheck, lang);
ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
todo_wine todo_wine
{ {
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r); ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
} }
HeapFree(GetProcessHeap(), 0, vercheck); HeapFree(GetProcessHeap(), 0, vercheck);