]> granicus.if.org Git - icu/commit
ICU-21778 UnicodeString::clone error handling fix
authorAndy Heninger <andy.heninger@gmail.com>
Sat, 30 Oct 2021 00:17:41 +0000 (17:17 -0700)
committerAndy Heninger <andy.heninger@gmail.com>
Fri, 5 Nov 2021 20:48:08 +0000 (13:48 -0700)
commitfd5a346b3de386b6e72ee72d17730f6cf116e9f5
treef16f0429c95e48be28afe967b5862e3eab123f3a
parent698efda42bb21a9da1c92348d3e73466c8a528fe
ICU-21778 UnicodeString::clone error handling fix

Change UnicodeString::clone() to return a nullptr if the underlying copy
constructor produces a bogus string. This can happen if the copy constructor
encounters a memory allocation failure in allocating the copy's internal string
buffer, or if the string being copied was already bogus.

The change is consistent with other ICU clone functions, which are generally
defined to return nullptr in case of errors.
icu4c/source/common/unistr.cpp
icu4c/source/test/intltest/ustrtest.cpp