[Base] Check success of sync primitive creation

- Mainly use `assert`s, since failure is very rare
- Forward failure of `CreateSemaphore` to guests because it is more easy
  to trigger with invalid initial parameters.
This commit is contained in:
Joel Linn
2022-02-24 22:37:32 +01:00
committed by Rick Gibbed
parent 6bd1279fc0
commit 986dcf4f65
21 changed files with 96 additions and 26 deletions

View File

@@ -590,7 +590,13 @@ dword_result_t NtCreateSemaphore_entry(lpdword_t handle_ptr,
}
auto sem = object_ref<XSemaphore>(new XSemaphore(kernel_state()));
sem->Initialize((int32_t)count, (int32_t)limit);
if (!sem->Initialize((int32_t)count, (int32_t)limit)) {
if (handle_ptr) {
*handle_ptr = 0;
}
sem->ReleaseHandle();
return X_STATUS_INVALID_PARAMETER;
}
// obj_attributes may have a name inside of it, if != NULL.
if (obj_attributes_ptr) {