mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
klocwork: fix risk issues
This commit is contained in:
committed by
Konstantinos Margaritis
parent
75dbedeebe
commit
978105a4c0
@@ -206,6 +206,10 @@ void makeCFG_top_edge(GoughGraph &cfg, const vector<GoughVertex> &vertices,
|
||||
assert(contains(src_slots, slot_id));
|
||||
|
||||
shared_ptr<GoughSSAVarMin> vmin = make_shared<GoughSSAVarMin>();
|
||||
if (!vmin) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
cfg[e].vars.emplace_back(vmin);
|
||||
final_var = vmin.get();
|
||||
|
||||
@@ -317,6 +321,10 @@ void makeCFG_edge(GoughGraph &cfg, const map<u32, u32> &som_creators,
|
||||
DEBUG_PRINTF("bypassing min on join %u\n", slot_id);
|
||||
} else {
|
||||
shared_ptr<GoughSSAVarMin> vmin = make_shared<GoughSSAVarMin>();
|
||||
if (!vmin) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
cfg[e].vars.emplace_back(vmin);
|
||||
final_var = vmin.get();
|
||||
|
||||
|
@@ -124,6 +124,10 @@ RepeatStateInfo::RepeatStateInfo(enum RepeatType type, const depth &repeatMin,
|
||||
const depth &repeatMax, u32 minPeriod)
|
||||
: stateSize(0), packedCtrlSize(0), horizon(0), patchCount(0),
|
||||
patchSize(0), encodingSize(0), patchesOffset(0) {
|
||||
if (type == REPEAT_SPARSE_OPTIMAL_P && minPeriod == 0) {
|
||||
assert(0);
|
||||
throw std::domain_error("SPARSE_OPTIMAL_P must have non-zero minPeriod.");
|
||||
}
|
||||
assert(repeatMin <= repeatMax);
|
||||
assert(repeatMax.is_reachable());
|
||||
assert(minPeriod || type != REPEAT_SPARSE_OPTIMAL_P);
|
||||
|
@@ -2445,6 +2445,10 @@ static
|
||||
bool doLitHaigSom(NG &ng, NGHolder &g, som_type som) {
|
||||
ue2_literal lit;
|
||||
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
|
||||
if (!rhs) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
if (!ng.cc.grey.allowLitHaig) {
|
||||
return false;
|
||||
}
|
||||
@@ -2509,6 +2513,11 @@ bool doHaigLitHaigSom(NG &ng, NGHolder &g,
|
||||
ue2_literal lit;
|
||||
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
|
||||
shared_ptr<NGHolder> lhs = make_shared<NGHolder>();
|
||||
if (!rhs || !lhs) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
if (!splitOffBestLiteral(g, regions, &lit, &*lhs, &*rhs, ng.cc)) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -1036,6 +1036,11 @@ bool splitRoseEdge(const NGHolder &base_graph, RoseInGraph &vg,
|
||||
shared_ptr<NGHolder> lhs = make_shared<NGHolder>();
|
||||
shared_ptr<NGHolder> rhs = make_shared<NGHolder>();
|
||||
|
||||
if (!lhs || !rhs) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
unordered_map<NFAVertex, NFAVertex> lhs_map;
|
||||
unordered_map<NFAVertex, NFAVertex> rhs_map;
|
||||
|
||||
@@ -1229,6 +1234,10 @@ void splitEdgesByCut(NGHolder &h, RoseInGraph &vg,
|
||||
DEBUG_PRINTF("splitting on pivot %zu\n", h[pivot].index);
|
||||
unordered_map<NFAVertex, NFAVertex> temp_map;
|
||||
shared_ptr<NGHolder> new_lhs = make_shared<NGHolder>();
|
||||
if (!new_lhs) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
splitLHS(h, pivot, new_lhs.get(), &temp_map);
|
||||
|
||||
/* want to cut off paths to pivot from things other than the pivot -
|
||||
@@ -1310,6 +1319,10 @@ void splitEdgesByCut(NGHolder &h, RoseInGraph &vg,
|
||||
if (!contains(done_rhs, adj)) {
|
||||
unordered_map<NFAVertex, NFAVertex> temp_map;
|
||||
shared_ptr<NGHolder> new_rhs = make_shared<NGHolder>();
|
||||
if (!new_rhs) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
splitRHS(h, adj, new_rhs.get(), &temp_map);
|
||||
remove_edge(new_rhs->start, new_rhs->accept, *new_rhs);
|
||||
remove_edge(new_rhs->start, new_rhs->acceptEod, *new_rhs);
|
||||
@@ -2281,6 +2294,10 @@ void splitEdgesForSuffix(const NGHolder &base_graph, RoseInGraph &vg,
|
||||
assert(!splitters.empty());
|
||||
|
||||
shared_ptr<NGHolder> lhs = make_shared<NGHolder>();
|
||||
if (!lhs) {
|
||||
assert(0);
|
||||
throw bad_alloc();
|
||||
}
|
||||
unordered_map<NFAVertex, NFAVertex> v_map;
|
||||
cloneHolder(*lhs, base_graph, &v_map);
|
||||
lhs->kind = NFA_INFIX;
|
||||
|
@@ -140,7 +140,8 @@ void ParsedLogical::validateSubIDs(const unsigned *ids,
|
||||
}
|
||||
hs_compile_error_t *compile_err = NULL;
|
||||
hs_expr_info_t *info = NULL;
|
||||
hs_error_t err = hs_expression_info(expressions[i], flags[i], &info,
|
||||
hs_error_t err = hs_expression_info(expressions[i],
|
||||
flags ? flags[i] : 0, &info,
|
||||
&compile_err);
|
||||
if (err != HS_SUCCESS) {
|
||||
hs_free_compile_error(compile_err);
|
||||
|
@@ -561,6 +561,10 @@ bool handleMixedPrefixCliche(const NGHolder &h, RoseGraph &g, RoseVertex v,
|
||||
DEBUG_PRINTF("woot?\n");
|
||||
|
||||
shared_ptr<NGHolder> h_new = make_shared<NGHolder>();
|
||||
if (!h_new) {
|
||||
assert(0);
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
unordered_map<NFAVertex, NFAVertex> rhs_map;
|
||||
vector<NFAVertex> exits_vec;
|
||||
insert(&exits_vec, exits_vec.end(), exits);
|
||||
|
@@ -77,7 +77,7 @@ namespace ue2 {
|
||||
struct LitTrieVertexProps {
|
||||
LitTrieVertexProps() = default;
|
||||
explicit LitTrieVertexProps(u8 c_in) : c(c_in) {}
|
||||
size_t index; // managed by ue2_graph
|
||||
size_t index = 0; // managed by ue2_graph
|
||||
u8 c = 0; //!< character reached on this vertex
|
||||
flat_set<ReportID> reports; //!< managed reports fired on this vertex
|
||||
};
|
||||
|
@@ -70,8 +70,8 @@ class undirected_graph_edge_descriptor
|
||||
using base_vertex_type = typename base_graph_traits::vertex_descriptor;
|
||||
|
||||
base_edge_type underlying_edge;
|
||||
const base_graph_type *g;
|
||||
bool reverse; // if true, reverse vertices in source() and target()
|
||||
const base_graph_type *g = nullptr;
|
||||
bool reverse = false; // if true, reverse vertices in source() and target()
|
||||
|
||||
inline std::pair<base_vertex_type, base_vertex_type>
|
||||
canonical_edge() const {
|
||||
|
@@ -133,7 +133,7 @@ public:
|
||||
: lit(&lit_in), idx(idx_in) {}
|
||||
|
||||
const ue2_literal *lit = nullptr;
|
||||
size_t idx;
|
||||
size_t idx = 0;
|
||||
};
|
||||
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
|
Reference in New Issue
Block a user