klocwork: fix risk issues

This commit is contained in:
Hong, Yang A
2022-05-31 06:30:18 +00:00
committed by Konstantinos Margaritis
parent 75dbedeebe
commit 978105a4c0
15 changed files with 61 additions and 10 deletions

View File

@@ -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();

View File

@@ -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);