libroot/add-ons/icu: Fix PVS V595

Check 'in' pointer against NULL before using it.

Change-Id: I4d7605df168b6e4f8a2ae61ff942ce1a8ba78321
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2203
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Murai Takashi 2020-01-28 20:30:55 +09:00 committed by waddlesplash
parent 24ffd29c7d
commit 0d56abf253

View File

@ -113,6 +113,11 @@ ICUCollateData::Strcoll(const char* a, const char* b, int& result)
status_t status_t
ICUCollateData::Strxfrm(char* out, const char* in, size_t size, size_t& outSize) ICUCollateData::Strxfrm(char* out, const char* in, size_t size, size_t& outSize)
{ {
if (in == NULL) {
outSize = 0;
return B_OK;
}
if (fCollator == NULL || strcmp(fPosixLocaleName, "POSIX") == 0) { if (fCollator == NULL || strcmp(fPosixLocaleName, "POSIX") == 0) {
// handle POSIX here as the collator ICU uses for that (english) is // handle POSIX here as the collator ICU uses for that (english) is
// incompatible in too many ways // incompatible in too many ways
@ -124,11 +129,6 @@ ICUCollateData::Strxfrm(char* out, const char* in, size_t size, size_t& outSize)
return B_OK; return B_OK;
} }
if (in == NULL) {
outSize = 0;
return B_OK;
}
UnicodeString unicodeIn; UnicodeString unicodeIn;
if (_ToUnicodeString(in, unicodeIn) != B_OK) if (_ToUnicodeString(in, unicodeIn) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;