[Base] Fix `Semaphore::Create` invalid parameters
This commit is contained in:
parent
bb42829308
commit
e75e0eb39c
|
@ -975,6 +975,10 @@ class PosixSemaphore : public PosixConditionHandle<Semaphore> {
|
|||
|
||||
std::unique_ptr<Semaphore> Semaphore::Create(int initial_count,
|
||||
int maximum_count) {
|
||||
if (initial_count < 0 || initial_count > maximum_count ||
|
||||
maximum_count <= 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<PosixSemaphore>(initial_count, maximum_count);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue