Another fix for 10800: Hang / memory exhaustion on numerical code (#3851)

* Another fix for 10800: Hang / memory exhaustion on numerical code

* Format
This commit is contained in:
Paul Fultz II 2022-02-22 00:21:26 -06:00 committed by GitHub
parent 72d0f3e444
commit 1ac16413ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -6874,6 +6874,12 @@ static bool needsInitialization(const Variable* var, bool cpp)
static void addToErrorPath(ValueFlow::Value& value, const ValueFlow::Value& from)
{
std::unordered_set<const Token*> locations;
std::transform(value.errorPath.begin(),
value.errorPath.end(),
std::inserter(locations, locations.begin()),
[](const ErrorPathItem& e) {
return e.first;
});
if (from.condition && !value.condition)
value.condition = from.condition;
std::copy_if(from.errorPath.begin(),

View File

@ -6318,6 +6318,23 @@ private:
" d(&f->a, c);\n"
"}\n";
valueOfTok(code, "f");
code = "struct bo {\n"
" int b, c, a, d;\n"
" char e, g, h, i, aa, j, k, l, m, n, o, p, q, r, t, u, v, w, x, y;\n"
" long z, ab, ac, ad, f, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar,\n"
" as;\n"
" short at, au, av, aw, ax, ay, az, ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk,\n"
" bl, bm;\n"
"};\n"
"char bn;\n"
"void bp() {\n"
" bo s;\n"
" if (bn)\n"
" return;\n"
" s;\n"
"}\n";
valueOfTok(code, "s");
}
void valueFlowHang() {