ICU-22584 Fix def of nullptr

ICU-22584 fix
This commit is contained in:
Frank Tang 2023-12-11 12:11:59 -08:00 committed by Frank Yung-Fong Tang
parent 4da7ffaa36
commit 7d3cd7cba5
2 changed files with 10 additions and 5 deletions

View file

@ -150,7 +150,7 @@ void RBBINode::NRDeleteNode(RBBINode *node) {
RBBINode *stopNode = node->fParent;
RBBINode *nextNode = node;
while (nextNode != stopNode) {
while (nextNode != stopNode && nextNode != nullptr) {
RBBINode *currentNode = nextNode;
if ((currentNode->fLeftChild == nullptr && currentNode->fRightChild == nullptr) ||
@ -158,10 +158,12 @@ void RBBINode::NRDeleteNode(RBBINode *node) {
currentNode->fType == setRef) { // own their children nodes.
// CurrentNode is effectively a leaf node; it's safe to go ahead and delete it.
nextNode = currentNode->fParent;
if (nextNode->fLeftChild == currentNode) {
nextNode->fLeftChild = nullptr;
} else if (nextNode->fRightChild == currentNode) {
nextNode->fRightChild = nullptr;
if (nextNode) {
if (nextNode->fLeftChild == currentNode) {
nextNode->fLeftChild = nullptr;
} else if (nextNode->fRightChild == currentNode) {
nextNode->fRightChild = nullptr;
}
}
delete currentNode;
} else if (currentNode->fLeftChild) {

View file

@ -5872,6 +5872,9 @@ void RBBITest::TestBug22584() {
UErrorCode ec {U_ZERO_ERROR};
RuleBasedBreakIterator bi(ruleStr, pe, ec);
ec = U_ZERO_ERROR;
ruleStr = u"a/b;c";
RuleBasedBreakIterator bi2(ruleStr, pe, ec);
}
void RBBITest::TestBug22581() {