From 03e1202db7090bb3e3efea51682bbf3feafce49d Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Wed, 2 Jul 2014 20:31:42 +0000 Subject: [PATCH] ICU-10983 Add failure checks to utext_clone(). X-SVN-Rev: 35986 --- icu4c/source/common/utext.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/icu4c/source/common/utext.cpp b/icu4c/source/common/utext.cpp index f16591fe5be..6dc31a0485d 100644 --- a/icu4c/source/common/utext.cpp +++ b/icu4c/source/common/utext.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2005-2013, International Business Machines +* Copyright (C) 2005-2014, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -516,8 +516,17 @@ utext_copy(UText *ut, U_CAPI UText * U_EXPORT2 utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status) { - UText *result; - result = src->pFuncs->clone(dest, src, deep, status); + if (U_FAILURE(*status)) { + return dest; + } + UText *result = src->pFuncs->clone(dest, src, deep, status); + if (U_FAILURE(*status)) { + return result; + } + if (result == NULL) { + *status = U_MEMORY_ALLOCATION_ERROR; + return result; + } if (readOnly) { utext_freeze(result); } -- 2.40.0