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.
diff --git a/icu4c/source/common/umutex.cpp b/icu4c/source/common/umutex.cpp
index 8be43bf..fe50d86 100644
--- a/icu4c/source/common/umutex.cpp
+++ b/icu4c/source/common/umutex.cpp
@@ -98,6 +98,7 @@
gListHead = this;
}
}
+ U_ASSERT(retPtr != nullptr);
return retPtr;
}
diff --git a/icu4c/source/common/umutex.h b/icu4c/source/common/umutex.h
index 13e38b4..d154ff8 100755
--- a/icu4c/source/common/umutex.h
+++ b/icu4c/source/common/umutex.h
@@ -240,7 +240,8 @@
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();
};