Cleanup excessive memory allocation check
Operator new throws rather than returns NULL. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
a052c028b5
commit
95fb94d828
@ -1281,19 +1281,11 @@ static _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle,
|
||||
if (GetTokenInformation(TokenHandle, TokenInformationClass, szStackBuffer, sizeof(szStackBuffer), &dwSize)) {
|
||||
// The stack buffer was big enough to retrieve complete data. Alloc and copy.
|
||||
TokenInformation.reset((_Ty*)(new BYTE[dwSize / sizeof(BYTE)]));
|
||||
if (!TokenInformation) {
|
||||
SetLastError(ERROR_OUTOFMEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(TokenInformation.get(), szStackBuffer, dwSize);
|
||||
return TRUE;
|
||||
} else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
// The stack buffer was too small to retrieve complete data. Alloc and retry.
|
||||
TokenInformation.reset((_Ty*)(new BYTE[dwSize / sizeof(BYTE)]));
|
||||
if (!TokenInformation) {
|
||||
SetLastError(ERROR_OUTOFMEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
return GetTokenInformation(TokenHandle, TokenInformationClass, TokenInformation.get(), dwSize, &dwSize);
|
||||
} else
|
||||
return FALSE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user