mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-20 20:19:32 +00:00
ICU-22581 Fix RBBI leakage
Duplicate variable references in the rule should not cause leakage
This commit is contained in:
parent
665d9dbbe9
commit
73f972f7ff
3 changed files with 18 additions and 0 deletions
|
@ -289,6 +289,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
|||
|
||||
// Terminate expression, leaves expression parse tree rooted in TOS node.
|
||||
fixOpStack(RBBINode::precStart);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
|
||||
RBBINode *startExprNode = fNodeStack[fNodeStackPtr-2];
|
||||
RBBINode *varRefNode = fNodeStack[fNodeStackPtr-1];
|
||||
|
@ -312,6 +315,11 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
|||
UErrorCode t = *fRB->fStatus;
|
||||
*fRB->fStatus = U_ZERO_ERROR;
|
||||
error(t);
|
||||
// When adding $variableRef to the symbol table fail, Delete
|
||||
// both nodes because deleting varRefNode will not delete
|
||||
// RHSExprNode internally.
|
||||
delete RHSExprNode;
|
||||
delete varRefNode;
|
||||
}
|
||||
|
||||
// Clean up the stack.
|
||||
|
|
|
@ -144,6 +144,7 @@ void RBBITest::runIndexedTest( int32_t index, UBool exec, const char* &name, cha
|
|||
TESTCASE_AUTO(TestRandomAccess);
|
||||
TESTCASE_AUTO(TestExternalBreakEngineWithFakeTaiLe);
|
||||
TESTCASE_AUTO(TestExternalBreakEngineWithFakeYue);
|
||||
TESTCASE_AUTO(TestBug22581);
|
||||
TESTCASE_AUTO(TestBug22584);
|
||||
|
||||
#if U_ENABLE_TRACING
|
||||
|
@ -5873,4 +5874,12 @@ void RBBITest::TestBug22584() {
|
|||
RuleBasedBreakIterator bi(ruleStr, pe, ec);
|
||||
}
|
||||
|
||||
void RBBITest::TestBug22581() {
|
||||
// Test duplicate variable setting will not leak the rule compilation
|
||||
UnicodeString ruleStr = u"$foo=[abc]; $foo=[xyz]; $foo;";
|
||||
UParseError pe {};
|
||||
UErrorCode ec {U_ZERO_ERROR};
|
||||
|
||||
RuleBasedBreakIterator bi(ruleStr, pe, ec);
|
||||
}
|
||||
#endif // #if !UCONFIG_NO_BREAK_ITERATION
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
void TestRandomAccess();
|
||||
void TestExternalBreakEngineWithFakeTaiLe();
|
||||
void TestExternalBreakEngineWithFakeYue();
|
||||
void TestBug22581();
|
||||
void TestBug22584();
|
||||
|
||||
#if U_ENABLE_TRACING
|
||||
|
|
Loading…
Add table
Reference in a new issue