From 95fb94d82807974ef5a0d4f4fa66029df4ac81b9 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 14 Oct 2022 14:00:16 +0200 Subject: [PATCH] Cleanup excessive memory allocation check Operator new throws rather than returns NULL. Signed-off-by: Simon Rozman --- include/WinStd/Win.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index 543c96be..70d76625 100644 --- a/include/WinStd/Win.h +++ b/include/WinStd/Win.h @@ -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;