From c699e987500d8553a6f81d50990129be4f3ab828 Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Mon, 19 Dec 2016 12:42:34 +1100 Subject: [PATCH] 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. --- src/nfa/mcsheng_compile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); } } }