Skip to content

Commit

Permalink
ICU-22903 Svace: Check values for NULL before access
Browse files Browse the repository at this point in the history
  • Loading branch information
ligurio committed Sep 20, 2024
1 parent b3bf9f8 commit f8b5fd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion icu4c/source/common/utrie2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,15 @@ enumEitherTrie(const UTrie2 *trie,
c+=UTRIE2_DATA_BLOCK_LENGTH;
} else {
for(j=0; j<UTRIE2_DATA_BLOCK_LENGTH; ++j) {
value=enumValue(context, data32!=nullptr ? data32[block+j] : idx[block+j]);
if (data32!=nullptr) {
value=enumValue(context, data32[block+j]);
} else if (idx!=nullptr) {
value=enumValue(context, idx[block+j]);
} else {
/* data32 and idx are not supposed to be NULL at the same time */
U_ASSERT(false);
return;
}
if(value!=prevValue) {
if(prev<c && !enumRange(context, prev, c-1, prevValue)) {
return;
Expand Down
4 changes: 3 additions & 1 deletion icu4c/source/i18n/unum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ unum_clone(const UNumberFormat *fmt,
} else {
const RuleBasedNumberFormat* rbnf = dynamic_cast<const RuleBasedNumberFormat*>(nf);
U_ASSERT(rbnf != nullptr);
res = rbnf->clone();
if (rbnf != nullptr) {
res = rbnf->clone();
}
}

if (res == nullptr) {
Expand Down

0 comments on commit f8b5fd8

Please sign in to comment.