Add explicit casts to succ table entry calculations.

Although overflow should not be possible given the range of alphaShift, this
resolves coverity scan issues CID 158536 and CID 158537.
This commit is contained in:
Alex Coyte 2016-12-19 12:42:34 +11:00 committed by Matthew Barr
parent 83e69cc195
commit c699e98750

View File

@ -606,7 +606,7 @@ void fill_in_succ_table_16(NFA *nfa, const dfa_info &info,
for (size_t s = 0; s < info.impl_alpha_size; s++) {
dstate_id_t raw_succ = info.states[i].next[s];
u16 &entry = succ_table[(normal_id << alphaShift) + s];
u16 &entry = succ_table[((size_t)normal_id << alphaShift) + s];
entry = info.implId(raw_succ);
entry |= get_edge_flags(nfa, entry);
@ -916,7 +916,8 @@ void fill_in_succ_table_8(NFA *nfa, const dfa_info &info,
for (size_t s = 0; s < info.impl_alpha_size; s++) {
dstate_id_t raw_succ = info.states[i].next[s];
succ_table[(normal_id << alphaShift) + s] = info.implId(raw_succ);
succ_table[((size_t)normal_id << alphaShift) + s]
= info.implId(raw_succ);
}
}
}