X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..f3c0d7a59d99c2a94c6b8822291f0e42be3773c9:/icuSources/common/rbbisetb.cpp diff --git a/icuSources/common/rbbisetb.cpp b/icuSources/common/rbbisetb.cpp index 5337738b..f55388ae 100644 --- a/icuSources/common/rbbisetb.cpp +++ b/icuSources/common/rbbisetb.cpp @@ -1,9 +1,11 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html // // rbbisetb.cpp // /* *************************************************************************** -* Copyright (C) 2002-2005 International Business Machines Corporation * +* Copyright (C) 2002-2008 International Business Machines Corporation * * and others. All rights reserved. * *************************************************************************** */ @@ -137,6 +139,10 @@ void RBBISetBuilder::build() { // that is in no sets. // fRangeList = new RangeDescriptor(*fStatus); // will check for status here + if (fRangeList == NULL) { + *fStatus = U_MEMORY_ALLOCATION_ERROR; + return; + } fRangeList->fStartChar = 0; fRangeList->fEndChar = 0x10ffff; @@ -354,6 +360,10 @@ void RBBISetBuilder::addValToSets(UVector *sets, uint32_t val) { void RBBISetBuilder::addValToSet(RBBINode *usetNode, uint32_t val) { RBBINode *leafNode = new RBBINode(RBBINode::leafChar); + if (leafNode == NULL) { + *fStatus = U_MEMORY_ALLOCATION_ERROR; + return; + } leafNode->fVal = (unsigned short)val; if (usetNode->fLeftChild == NULL) { usetNode->fLeftChild = leafNode; @@ -363,6 +373,10 @@ void RBBISetBuilder::addValToSet(RBBINode *usetNode, uint32_t val) { // Set up an OR node, with the previous stuff as the left child // and the new value as the right child. RBBINode *orNode = new RBBINode(RBBINode::opOr); + if (orNode == NULL) { + *fStatus = U_MEMORY_ALLOCATION_ERROR; + return; + } orNode->fLeftChild = usetNode->fLeftChild; orNode->fRightChild = leafNode; orNode->fLeftChild->fParent = orNode; @@ -510,7 +524,7 @@ void RBBISetBuilder::printSets() { RBBIDebugPrintf("\n\nUnicode Sets List\n------------------\n"); for (i=0; ; i++) { - RBBINode *usetNode; + RBBINode *usetNode; RBBINode *setRef; RBBINode *varRef; UnicodeString setName; @@ -534,7 +548,7 @@ void RBBISetBuilder::printSets() { RBBI_DEBUG_printUnicodeString(usetNode->fText); RBBIDebugPrintf("\n"); if (usetNode->fLeftChild != NULL) { - usetNode->fLeftChild->printTree(TRUE); + RBBINode::printTree(usetNode->fLeftChild, TRUE); } } RBBIDebugPrintf("\n"); @@ -621,15 +635,14 @@ RangeDescriptor::~RangeDescriptor() { void RangeDescriptor::split(UChar32 where, UErrorCode &status) { U_ASSERT(where>fStartChar && where<=fEndChar); RangeDescriptor *nr = new RangeDescriptor(*this, status); - if (U_FAILURE(status)) { - return; - } - /* test for NULL */ if(nr == 0) { status = U_MEMORY_ALLOCATION_ERROR; return; } - + if (U_FAILURE(status)) { + delete nr; + return; + } // RangeDescriptor copy constructor copies all fields. // Only need to update those that are different after the split. nr->fStartChar = where;