]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Add explicit casts to succ table entry calculations.
authorAlex Coyte <a.coyte@intel.com>
Mon, 19 Dec 2016 01:42:34 +0000 (12:42 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 6 Jan 2017 00:22:26 +0000 (11:22 +1100)
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

index a7713bb061a9b1b0dc6133cf250b3038f506d141..7b4e58ab192274b3590b5b92e00b8d5c925ffb46 100644 (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);
         }
     }
 }