advapi32: avicap32: fix missing allocation checks, and incorrect free calls by andygui

CORE-7197 #resolve #comment Committed in revision r59243, thanks for help

svn path=/trunk/; revision=59244
This commit is contained in:
Daniel Reimer 2013-06-16 22:15:28 +00:00
parent 30262ea0ce
commit d67db490fb
3 changed files with 28 additions and 14 deletions

View file

@ -650,7 +650,7 @@ LogonUserW(LPWSTR lpszUsername,
/* Get the user SID from the registry */
if (!GetUserSid (lpszUsername, &UserSid))
{
ERR("SamGetUserSid() failed\n");
ERR("GetUserSid() failed\n");
return FALSE;
}

View file

@ -678,7 +678,7 @@ ConvertSecurityDescriptorToStringSecurityDescriptorW(PSECURITY_DESCRIPTOR Securi
if (SDRevision != SDDL_REVISION_1)
{
ERR("Pogram requested unknown SDDL revision %d\n", SDRevision);
ERR("Program requested unknown SDDL revision %d\n", SDRevision);
SetLastError(ERROR_UNKNOWN_REVISION);
return FALSE;
}
@ -698,6 +698,9 @@ ConvertSecurityDescriptorToStringSecurityDescriptorW(PSECURITY_DESCRIPTOR Securi
return FALSE;
wstr = wptr = LocalAlloc(0, (len + 1)*sizeof(WCHAR));
if (wstr == NULL)
return FALSE;
if (SecurityInformation & OWNER_SECURITY_INFORMATION)
if (!DumpOwner(SecurityDescriptor, &wptr, NULL))
return FALSE;
@ -740,6 +743,12 @@ ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCRIPTOR Securi
lenA = WideCharToMultiByte(CP_ACP, 0, wstr, len, NULL, 0, NULL, NULL);
*OutputString = HeapAlloc(GetProcessHeap(), 0, lenA);
if (*OutputString == NULL)
{
LocalFree(wstr);
*OutputLen = 0;
return FALSE;
}
WideCharToMultiByte(CP_ACP, 0, wstr, len, *OutputString, lenA, NULL, NULL);
LocalFree(wstr);
@ -1786,6 +1795,8 @@ ConvertStringSidToSidA(IN LPCSTR StringSid,
{
UINT len = MultiByteToWideChar(CP_ACP, 0, StringSid, -1, NULL, 0);
LPWSTR wStringSid = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (wStringSid == NULL)
return FALSE;
MultiByteToWideChar(CP_ACP, 0, StringSid, - 1, wStringSid, len);
bRetVal = ConvertStringSidToSidW(wStringSid, sid);
HeapFree(GetProcessHeap(), 0, wStringSid);

View file

@ -218,21 +218,24 @@ capGetDriverDescriptionW(WORD wDriverIndex,
if (dwInfoSize)
{
Version = HeapAlloc(GetProcessHeap(), 0, dwInfoSize);
GetFileVersionInfo(szFileName, 0, dwInfoSize, Version);
if (VerQueryValueW(Version, L"\\", &Ms, &Ls))
if (Version != NULL)
{
memmove(&FileInfo, Ms, Ls);
swprintf(szVersion, L"Version: %d.%d.%d.%d",
HIWORD(FileInfo.dwFileVersionMS),
LOWORD(FileInfo.dwFileVersionMS),
HIWORD(FileInfo.dwFileVersionLS),
LOWORD(FileInfo.dwFileVersionLS));
GetFileVersionInfo(szFileName, 0, dwInfoSize, Version);
lstrcpynW(lpszVer, szVersion, cbVer);
if (VerQueryValueW(Version, L"\\", &Ms, &Ls))
{
memmove(&FileInfo, Ms, Ls);
swprintf(szVersion, L"Version: %d.%d.%d.%d",
HIWORD(FileInfo.dwFileVersionMS),
LOWORD(FileInfo.dwFileVersionMS),
HIWORD(FileInfo.dwFileVersionLS),
LOWORD(FileInfo.dwFileVersionLS));
lstrcpynW(lpszVer, szVersion, cbVer);
}
HeapFree(GetProcessHeap(), 0, Version);
}
HeapFree(GetProcessHeap(), 0, Version);
}
}