Skip to content

Commit 315b26d

Browse files
committed
#20 ensure that allocation failure results in an error return value
1 parent 9d920aa commit 315b26d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/TaskManagerIO.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ taskid_t TaskManager::findFreeTask() {
8686
TmSpinLock spinLock(&memLockerFlag);
8787
auto nextIdSpace = taskBlocks[numberOfBlocks - 1]->lastSlot() + 1;
8888
taskBlocks[numberOfBlocks] = new TaskBlock(nextIdSpace);
89-
tm_internal::tmNotification(tm_internal::TM_INFO_REALLOC, numberOfBlocks);
90-
numberOfBlocks++;
89+
if(taskBlocks[numberOfBlocks] != nullptr) {
90+
tm_internal::tmNotification(tm_internal::TM_INFO_REALLOC, numberOfBlocks);
91+
numberOfBlocks++;
92+
}
93+
else {
94+
tm_internal::tmNotification(tm_internal::TM_ERROR_FULL, numberOfBlocks);
95+
break; // no point to continue here, new has failed.
96+
}
9197
}
9298

9399
// count up the tries so far to allocate / wait for allocation.

0 commit comments

Comments
 (0)