Fix a crasher when allocating the last Job

Instead of returning nullptr, the pool allocator returned an
invalid pointer.
This commit is contained in:
Mathias Agopian
2018-11-06 13:22:56 -08:00
committed by Mathias Agopian
parent e580bfed56
commit 591c9f2454
2 changed files with 3 additions and 3 deletions

View File

@@ -336,13 +336,13 @@ private:
Job* pop(WorkQueue& workQueue) noexcept {
size_t index = workQueue.pop();
assert(index <= MAX_JOB_COUNT);
return !index ? nullptr : (mJobStorageBase - 1) + index;
return !index ? nullptr : &mJobStorageBase[index - 1];
}
Job* steal(WorkQueue& workQueue) noexcept {
size_t index = workQueue.steal();
assert(index <= MAX_JOB_COUNT);
return !index ? nullptr : (mJobStorageBase - 1) + index;
return !index ? nullptr : &mJobStorageBase[index - 1];
}
// these have thread contention, keep them together