Remove E_OUTOFMEMORY check for new. (#863)

This commit is contained in:
Justin Kotalik 2018-05-25 09:30:06 -07:00 committed by GitHub
parent 44c8e77ee6
commit d041f89c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 15 additions and 160 deletions

View File

@ -106,11 +106,6 @@ public:
if(m_pApplicationInfoHash == NULL)
{
m_pApplicationInfoHash = new APPLICATION_INFO_HASH();
if(m_pApplicationInfoHash == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = m_pApplicationInfoHash->Initialize(DEFAULT_HASH_BUCKETS);
if(FAILED(hr))

View File

@ -66,11 +66,6 @@ APPLICATION_INFO::Initialize(
if (m_pFileWatcherEntry == NULL)
{
m_pFileWatcherEntry = new FILE_WATCHER_ENTRY(pFileWatcher);
if (m_pFileWatcherEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
}
UpdateAppOfflineFileHandle();

View File

@ -76,11 +76,6 @@ APPLICATION_MANAGER::GetOrCreateApplicationInfo(
goto Finished;
}
pApplicationInfo = new APPLICATION_INFO(pServer);
if (pApplicationInfo == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
AcquireSRWLockExclusive(&m_srwLock);
fExclusiveLock = TRUE;
@ -286,12 +281,6 @@ APPLICATION_MANAGER::RecycleApplicationFromManager(
// This will be used for finding differences in which applications are affected by a config change.
table = new APPLICATION_INFO_HASH();
if (table == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
// few application expected, small bucket size for hash table
if (FAILED(hr = table->Initialize(17 /*prime*/)))
{

View File

@ -61,11 +61,6 @@ ASPNETCORE_SHIM_CONFIG::GetConfig(
}
pAspNetCoreShimConfig = new ASPNETCORE_SHIM_CONFIG;
if (pAspNetCoreShimConfig == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pAspNetCoreShimConfig->Populate(pHttpServer, pHttpApplication);
if (FAILED(hr))

View File

@ -182,12 +182,6 @@ HRESULT
//
pFactory = new ASPNET_CORE_PROXY_MODULE_FACTORY;
if (pFactory == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pModuleInfo->SetRequestNotifications(
pFactory,
RQ_EXECUTE_REQUEST_HANDLER,
@ -199,11 +193,6 @@ HRESULT
pFactory = NULL;
pApplicationManager = APPLICATION_MANAGER::GetInstance();
if(pApplicationManager == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pApplicationManager->Initialize();
if(FAILED(hr))
@ -213,11 +202,6 @@ HRESULT
pGlobalModule = NULL;
pGlobalModule = new ASPNET_CORE_GLOBAL_MODULE(pApplicationManager);
if (pGlobalModule == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pModuleInfo->SetGlobalNotifications(
pGlobalModule,

View File

@ -16,7 +16,6 @@ ASPNET_CORE_PROXY_MODULE_FACTORY::GetHttpModule(
{
return E_OUTOFMEMORY;
}
*ppModule = pModule;
return S_OK;
}
@ -97,11 +96,6 @@ ASPNET_CORE_PROXY_MODULE::OnExecuteRequestHandler(
}
pApplicationManager = APPLICATION_MANAGER::GetInstance();
if (pApplicationManager == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pApplicationManager->GetOrCreateApplicationInfo(
g_pHttpServer,

View File

@ -206,11 +206,6 @@ public:
ENVIRONMENT_VAR_HASH* pEnvironmentVarTable = NULL;
pEnvironmentVarTable = new ENVIRONMENT_VAR_HASH();
if (pEnvironmentVarTable == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
//
// few environment variables expected, small bucket size for hash table
@ -258,11 +253,7 @@ public:
}
pIISAuthEntry = new ENVIRONMENT_VAR_ENTRY();
if (pIISAuthEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(hr = pIISAuthEntry->Initialize(ASPNETCORE_IIS_AUTH_ENV_STR, strIisAuthEnvValue.QueryStr())) ||
FAILED(hr = pEnvironmentVarTable->InsertRecord(pIISAuthEntry)))
{
@ -329,11 +320,7 @@ public:
// the environment variable was not defined, create it and add to hashtable
pHostingEntry = new ENVIRONMENT_VAR_ENTRY();
if (pHostingEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(hr = pHostingEntry->Initialize(HOSTING_STARTUP_ASSEMBLIES_NAME, strStartupAssemblyEnv.QueryStr())) ||
FAILED(hr = pEnvironmentVarTable->InsertRecord(pHostingEntry)))
{
@ -403,11 +390,7 @@ public:
}
pIISWebsocketEntry = new ENVIRONMENT_VAR_ENTRY();
if (pIISWebsocketEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(hr = pIISWebsocketEntry->Initialize(ASPNETCORE_IIS_WEBSOCKETS_SUPPORTED_ENV_STR, strIISWebsocketEnvValue.QueryStr())) ||
FAILED(hr = pInEnvironmentVarTable->InsertRecord(pIISWebsocketEntry)))
{

View File

@ -226,7 +226,8 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
goto Finished;
}
if (FAILED(hr = pStruExeAbsolutePath->Copy(struAbsolutePathToDotnet))) {
if (FAILED(hr = pStruExeAbsolutePath->Copy(struAbsolutePathToDotnet)))
{
goto Finished;
}
}
@ -252,7 +253,8 @@ HOSTFXR_UTILITY::GetHostFxrParameters(
goto Finished;
}
if (FAILED(hr = pStruExeAbsolutePath->Copy(struAbsolutePathToDotnet))) {
if (FAILED(hr = pStruExeAbsolutePath->Copy(struAbsolutePathToDotnet)))
{
goto Finished;
}
}
@ -299,6 +301,7 @@ HOSTFXR_UTILITY::ParseHostfxrArguments(
DBG_ASSERT(dwArgCount != NULL);
DBG_ASSERT(pwzArgv != NULL);
DBG_ASSERT(pwzExePath != NULL);
HRESULT hr = S_OK;
INT argc = 0;
@ -324,24 +327,18 @@ HOSTFXR_UTILITY::ParseHostfxrArguments(
}
argv = new BSTR[argc + 1];
if (argv == NULL)
{
hr = E_OUTOFMEMORY;
goto Failure;
}
argv[0] = SysAllocString(pwzExePath);
if (argv[0] == NULL)
{
hr = E_OUTOFMEMORY;
goto Failure;
}
// Try to convert the application dll from a relative to an absolute path
// Don't record this failure as pwzArgs[0] may already be an absolute path to the dll.
for (intArgsProcessed = 0; intArgsProcessed < argc; intArgsProcessed++)
{
DBG_ASSERT(pwzArgs[intArgsProcessed] != NULL);
struTempPath.Copy(pwzArgs[intArgsProcessed]);
if (struTempPath.EndsWith(L".dll"))
{

View File

@ -42,11 +42,6 @@ REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(
*ppAspNetCoreConfig = NULL;
pRequestHandlerConfig = new REQUESTHANDLER_CONFIG;
if (pRequestHandlerConfig == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pRequestHandlerConfig->Populate(pHttpServer, pHttpApplication);
if (FAILED(hr))
@ -110,11 +105,6 @@ REQUESTHANDLER_CONFIG::Populate(
BSTR bstrAspNetCoreSection = NULL;
m_pEnvironmentVariables = new ENVIRONMENT_VAR_HASH();
if (m_pEnvironmentVariables == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(hr = m_pEnvironmentVariables->Initialize(37 /*prime*/)))
{
delete m_pEnvironmentVariables;
@ -168,7 +158,6 @@ REQUESTHANDLER_CONFIG::Populate(
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pAdminManager->GetAdminSection(bstrWindowAuthSection,
m_struConfigPath.QueryStr(),
&pWindowsAuthenticationElement);
@ -196,6 +185,7 @@ REQUESTHANDLER_CONFIG::Populate(
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pAdminManager->GetAdminSection(bstrBasicAuthSection,
m_struConfigPath.QueryStr(),
&pBasicAuthenticationElement);
@ -213,12 +203,14 @@ REQUESTHANDLER_CONFIG::Populate(
goto Finished;
}
}
bstrAnonymousAuthSection = SysAllocString(CS_ANONYMOUS_AUTHENTICATION_SECTION);
if (bstrAnonymousAuthSection == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pAdminManager->GetAdminSection(bstrAnonymousAuthSection,
m_struConfigPath.QueryStr(),
&pAnonymousAuthenticationElement);
@ -419,11 +411,6 @@ REQUESTHANDLER_CONFIG::Populate(
}
pEntry = new ENVIRONMENT_VAR_ENTRY();
if (pEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(hr = pEntry->Initialize(strEnvName.QueryStr(), strExpandedEnvValue.QueryStr())) ||
FAILED(hr = m_pEnvironmentVariables->InsertRecord(pEntry)))

View File

@ -409,11 +409,6 @@ UTILITY::ConvertPathToFullPath(
}
pszFullPath = new WCHAR[ strFileFullPath.QueryCCH() + 1];
if ( pszFullPath == NULL )
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if(_wfullpath( pszFullPath,
strFileFullPath.QueryStr(),

View File

@ -53,6 +53,9 @@ http_get_server_variable(
{
PCWSTR pszVariableValue;
DWORD cbLength;
DBG_ASSERT(pszVariableValue != NULL);
HRESULT hr = pInProcessHandler
->QueryHttpContext()
->GetServerVariable(pszVariableName, &pszVariableValue, &cbLength);
@ -69,7 +72,6 @@ http_get_server_variable(
hr = E_OUTOFMEMORY;
goto Finished;
}
Finished:
return hr;
}

View File

@ -208,11 +208,6 @@ FORWARDING_HANDLER::OnExecuteRequestHandler()
if (m_pDisconnect == NULL)
{
m_pDisconnect = new ASYNC_DISCONNECT_CONTEXT();
if (m_pDisconnect == NULL)
{
hr = E_OUTOFMEMORY;
goto Failure;
}
hr = pClientConnection->GetModuleContextContainer()->
SetConnectionModuleContext(m_pDisconnect,
@ -459,11 +454,6 @@ REQUEST_NOTIFICATION_STATUS
// This should be the write completion of the 101 response.
//
m_pWebSocket = new WEBSOCKET_HANDLER();
if (m_pWebSocket == NULL)
{
hr = E_OUTOFMEMORY;
goto Failure;
}
hr = m_pWebSocket->ProcessRequest(this, m_pW3Context, m_hRequest, &fWebSocketUpgraded);
if (fWebSocketUpgraded)
@ -718,11 +708,6 @@ HRESULT
HRESULT hr = S_OK;
sm_pAlloc = new ALLOC_CACHE_HANDLER;
if (sm_pAlloc == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = sm_pAlloc->Initialize(sizeof(FORWARDING_HANDLER),
64); // nThreshold
@ -732,11 +717,6 @@ HRESULT
}
sm_pResponseHeaderHash = new RESPONSE_HEADER_HASH;
if (sm_pResponseHeaderHash == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = sm_pResponseHeaderHash->Initialize();
if (FAILED(hr))

View File

@ -34,11 +34,6 @@ OUT_OF_PROCESS_APPLICATION::Initialize(
if (m_pProcessManager == NULL)
{
m_pProcessManager = new PROCESS_MANAGER;
if (m_pProcessManager == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = m_pProcessManager->Initialize();
if (FAILED(hr))

View File

@ -123,11 +123,6 @@ PROCESS_MANAGER::GetProcess(
{
m_dwProcessesPerApplication = pConfig->QueryProcessesPerApplication();
m_ppServerProcessList = new SERVER_PROCESS*[m_dwProcessesPerApplication];
if (m_ppServerProcessList == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
for (DWORD i = 0; i < m_dwProcessesPerApplication; ++i)
{
@ -203,12 +198,6 @@ PROCESS_MANAGER::GetProcess(
{
pSelectedServerProcess = new SERVER_PROCESS();
if (pSelectedServerProcess == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = pSelectedServerProcess->Initialize(
this, //ProcessManager

View File

@ -187,11 +187,6 @@ SERVER_PROCESS::SetupListenPort(
}
pEntry = new ENVIRONMENT_VAR_ENTRY();
if (pEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(hr = pEntry->Initialize(ASPNETCORE_PORT_ENV_STR, buffer)) ||
FAILED(hr = pEnvironmentVarTable->InsertRecord(pEntry)) ||
@ -242,11 +237,6 @@ SERVER_PROCESS::SetupAppPath(
}
pEntry = new ENVIRONMENT_VAR_ENTRY();
if (pEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(hr = pEntry->Initialize(ASPNETCORE_APP_PATH_ENV_STR, m_struAppVirtualPath.QueryStr())) ||
FAILED(hr = pEnvironmentVarTable->InsertRecord(pEntry)))
@ -314,11 +304,6 @@ SERVER_PROCESS::SetupAppToken(
}
pEntry = new ENVIRONMENT_VAR_ENTRY();
if (pEntry == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (FAILED(strAppToken.CopyA(m_straGuid.QueryStr())) ||
FAILED(hr = pEntry->Initialize(ASPNETCORE_APP_TOKEN_ENV_STR, strAppToken.QueryStr())) ||
@ -458,11 +443,6 @@ SERVER_PROCESS::SetupCommandLine(
dwBufferSize = strRelativePath.QueryCCH() + 1;
pszFullPath = new WCHAR[dwBufferSize];
if (pszFullPath == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
if (_wfullpath(pszFullPath,
strRelativePath.QueryStr(),
@ -694,11 +674,6 @@ SERVER_PROCESS::PostStartCheck(
if (m_pForwarderConnection == NULL)
{
m_pForwarderConnection = new FORWARDER_CONNECTION();
if (m_pForwarderConnection == NULL)
{
hr = E_OUTOFMEMORY;
goto Finished;
}
hr = m_pForwarderConnection->Initialize(m_dwPort);
if (FAILED(hr))