summaryrefslogtreecommitdiff
path: root/src/gc/objecthandle.cpp
diff options
context:
space:
mode:
authorSean Gillespie <sean@swgillespie.me>2017-04-24 10:44:25 -0700
committerGitHub <noreply@github.com>2017-04-24 10:44:25 -0700
commit69d43a0f8cfe095336b286e7bb892fe49c702e30 (patch)
treef821902c8b213afd95f953f08ae079ba8a824da6 /src/gc/objecthandle.cpp
parent5c8b9a6870a58e0af250ff822ca395e3fd8268bb (diff)
downloadcoreclr-69d43a0f8cfe095336b286e7bb892fe49c702e30.tar.gz
coreclr-69d43a0f8cfe095336b286e7bb892fe49c702e30.tar.bz2
coreclr-69d43a0f8cfe095336b286e7bb892fe49c702e30.zip
[Local GC] Ensure that handle creation returns null on failure instead of throwing (#11092)
* [Local GC] Ensure that handle creation returns null on failure instead of throwing * Fix some clang pedantry about jumping past variable initialization * Throw OOM if initialization of handle store fails * Perform the handle OOM check in each handle helper
Diffstat (limited to 'src/gc/objecthandle.cpp')
-rw-r--r--src/gc/objecthandle.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/gc/objecthandle.cpp b/src/gc/objecthandle.cpp
index cd64ae23f9..dd43ec23d5 100644
--- a/src/gc/objecthandle.cpp
+++ b/src/gc/objecthandle.cpp
@@ -740,9 +740,9 @@ bool Ref_InitializeHandleTableBucket(HandleTableBucket* bucket, void* context)
{
CONTRACTL
{
- THROWS;
+ NOTHROW;
WRAPPER(GC_TRIGGERS);
- INJECT_FAULT(COMPlusThrowOM());
+ INJECT_FAULT(return false);
}
CONTRACTL_END;
@@ -759,13 +759,18 @@ bool Ref_InitializeHandleTableBucket(HandleTableBucket* bucket, void* context)
HandleTableBucketHolder bucketHolder(result, n_slots);
- result->pTable = new HHANDLETABLE[n_slots];
+ result->pTable = new (nothrow) HHANDLETABLE[n_slots];
+ if (!result->pTable)
+ {
+ return false;
+ }
+
ZeroMemory(result->pTable, n_slots * sizeof(HHANDLETABLE));
for (int uCPUindex=0; uCPUindex < n_slots; uCPUindex++) {
result->pTable[uCPUindex] = HndCreateHandleTable(s_rgTypeFlags, _countof(s_rgTypeFlags), ADIndex((DWORD)(uintptr_t)context));
if (!result->pTable[uCPUindex])
- COMPlusThrowOM();
+ return false;
}
for (;;) {
@@ -792,9 +797,18 @@ bool Ref_InitializeHandleTableBucket(HandleTableBucket* bucket, void* context)
// No free slot.
// Let's create a new node
NewHolder<HandleTableMap> newMap;
- newMap = new HandleTableMap;
+ newMap = new (nothrow) HandleTableMap;
+ if (!newMap)
+ {
+ return false;
+ }
+
+ newMap->pBuckets = new (nothrow) HandleTableBucket * [ INITIAL_HANDLE_TABLE_ARRAY_SIZE ];
+ if (!newMap->pBuckets)
+ {
+ return false;
+ }
- newMap->pBuckets = new HandleTableBucket * [ INITIAL_HANDLE_TABLE_ARRAY_SIZE ];
newMap.SuppressRelease();
newMap->dwMaxIndex = last->dwMaxIndex + INITIAL_HANDLE_TABLE_ARRAY_SIZE;