ICU-20776 Checks for nullness in UMutex::lock()

Adds `U_ASSERT` check before using `m->lock()` to make allocation issues
more apparent at least in debug builds.

There is probably quite a few places like this, but let's try fixing
broken windows.
This commit is contained in:
Filip Filmar 2019-08-14 18:32:43 -07:00 committed by Jeff Genovy
parent c5ad4664f9
commit 0a01b29005
2 changed files with 3 additions and 1 deletions
icu4c/source/common

View file

@ -98,6 +98,7 @@ std::mutex *UMutex::getMutex() {
gListHead = this;
}
}
U_ASSERT(retPtr != nullptr);
return retPtr;
}

View file

@ -240,7 +240,8 @@ private:
static UMutex *gListHead;
/** Out-of-line function to lazily initialize a UMutex on first use.
* Initial fast check is inline, in lock().
* Initial fast check is inline, in lock(). The returned value may never
* be nullptr.
*/
std::mutex *getMutex();
};