From: Alex Coyte Date: Mon, 19 Dec 2016 01:42:34 +0000 (+1100) Subject: Add explicit casts to succ table entry calculations. X-Git-Tag: v4.4.0^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c699e987500d8553a6f81d50990129be4f3ab828;p=thirdparty%2Fvectorscan.git 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. --- diff --git a/src/nfa/mcsheng_compile.cpp b/src/nfa/mcsheng_compile.cpp index a7713bb0..7b4e58ab 100644 --- a/src/nfa/mcsheng_compile.cpp +++ b/src/nfa/mcsheng_compile.cpp @@ -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); } } }