@@ -1498,33 +1498,45 @@ CMNode* DFAContentModel::buildSyntaxTree(ContentSpecNode* const curNode
14981498 retNode = buildSyntaxTree (cursor, curIndex);
14991499 for (unsigned int i=0 ;i<nLoopCount;i++)
15001500 {
1501- CMNode* newRight = buildSyntaxTree (rightNode, curIndex);
1502- //
1503- // Now handle our level. We use our left child's last pos set and our
1504- // right child's first pos set, so get them now for convenience.
1505- //
1506- const CMStateSet& last = retNode->getLastPos ();
1507- const CMStateSet& first = newRight->getFirstPos ();
1501+ CMNode* newRight = nullptr ;
1502+ try
1503+ {
1504+ newRight = buildSyntaxTree (rightNode, curIndex);
15081505
1509- //
1510- // Now, for every position which is in our left child's last set
1511- // add all of the states in our right child's first set to the
1512- // follow set for that position.
1513- //
1514- CMStateSetEnumerator enumLast (&last);
1515- while (enumLast.hasMoreElements ())
1506+ //
1507+ // Now handle our level. We use our left child's last pos set and our
1508+ // right child's first pos set, so get them now for convenience.
1509+ //
1510+ const CMStateSet& last = retNode->getLastPos ();
1511+ const CMStateSet& first = newRight->getFirstPos ();
1512+
1513+ //
1514+ // Now, for every position which is in our left child's last set
1515+ // add all of the states in our right child's first set to the
1516+ // follow set for that position.
1517+ //
1518+ CMStateSetEnumerator enumLast (&last);
1519+ while (enumLast.hasMoreElements ())
1520+ {
1521+ XMLSize_t index=enumLast.nextElement ();
1522+ *fFollowList [index] |= first;
1523+ }
1524+
1525+ retNode = new (fMemoryManager ) CMBinaryOp
1526+ (
1527+ ContentSpecNode::Sequence
1528+ , retNode
1529+ , newRight
1530+ , fLeafCount
1531+ , fMemoryManager
1532+ );
1533+ }
1534+ catch ( const OutOfMemoryException& )
15161535 {
1517- XMLSize_t index=enumLast.nextElement ();
1518- *fFollowList [index] |= first;
1536+ delete newRight;
1537+ delete retNode;
1538+ throw ;
15191539 }
1520- retNode = new (fMemoryManager ) CMBinaryOp
1521- (
1522- ContentSpecNode::Sequence
1523- , retNode
1524- , newRight
1525- , fLeafCount
1526- , fMemoryManager
1527- );
15281540 }
15291541 return retNode;
15301542 }
0 commit comments