@@ -113,11 +113,17 @@ NFRule::makeRules(UnicodeString& description,
113
113
NFRuleList& rules,
114
114
UErrorCode& status)
115
115
{
116
+ if (U_FAILURE (status)) {
117
+ return ;
118
+ }
116
119
// we know we're making at least one rule, so go ahead and
117
120
// new it up and initialize its basevalue and divisor
118
121
// (this also strips the rule descriptor, if any, off the
119
122
// description string)
120
123
LocalPointer<NFRule> rule1 (new NFRule (rbnf, description, status));
124
+ if (U_FAILURE (status)) {
125
+ return ;
126
+ }
121
127
/* test for nullptr */
122
128
if (rule1.isNull ()) {
123
129
status = U_MEMORY_ALLOCATION_ERROR;
@@ -141,6 +147,9 @@ NFRule::makeRules(UnicodeString& description,
141
147
|| rule1->getType () == kNaNRule )
142
148
{
143
149
rule1->extractSubstitutions (owner, description, predecessor, status);
150
+ if (U_FAILURE (status)) {
151
+ return ;
152
+ }
144
153
}
145
154
else {
146
155
// if the description does contain a matched pair of brackets,
@@ -164,6 +173,9 @@ NFRule::makeRules(UnicodeString& description,
164
173
// increment the original rule's base value ("rule1" actually
165
174
// goes SECOND in the rule set's rule list)
166
175
rule2.adoptInstead (new NFRule (rbnf, UnicodeString (), status));
176
+ if (U_FAILURE (status)) {
177
+ return ;
178
+ }
167
179
/* test for nullptr */
168
180
if (rule2.isNull ()) {
169
181
status = U_MEMORY_ALLOCATION_ERROR;
@@ -207,6 +219,9 @@ NFRule::makeRules(UnicodeString& description,
207
219
sbuf.append (description, brack2 + 1 , description.length () - brack2 - 1 );
208
220
}
209
221
rule2->extractSubstitutions (owner, sbuf, predecessor, status);
222
+ if (U_FAILURE (status)) {
223
+ return ;
224
+ }
210
225
}
211
226
212
227
// rule1's text includes the text in the brackets but omits
@@ -223,6 +238,9 @@ NFRule::makeRules(UnicodeString& description,
223
238
sbuf.append (description, brack2 + 1 , description.length () - brack2 - 1 );
224
239
}
225
240
rule1->extractSubstitutions (owner, sbuf, predecessor, status);
241
+ if (U_FAILURE (status)) {
242
+ return ;
243
+ }
226
244
227
245
// if we only have one rule, return it; if we have two, return
228
246
// a two-element array containing them (notice that rule2 goes
0 commit comments