Fix 10677: crash during valueFlowInferCondition (#3687)

This commit is contained in:
Paul Fultz II 2022-01-09 15:43:08 -06:00 committed by GitHub
parent 4a3a287248
commit fe7595cd9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -4450,6 +4450,8 @@ static std::vector<const Token*> getConditions(const Token* tok, const char* op)
return false;
if (tok2->hasKnownIntValue())
return false;
if (Token::Match(tok2, "%var%") && !astIsBool(tok2))
return false;
return true;
});
}

View File

@ -6173,6 +6173,18 @@ private:
" ASSERT(!(t4 < t5) && t4 <= t5);\n"
"}";
valueOfTok(code, "<=");
code = "void f() {\n"
" unsigned short Xoff = 10;\n"
" unsigned short Nx = 0;\n"
" int last;\n"
" do {\n"
" last = readData(0);\n"
" if (last && (last - Xoff < Nx))\n"
" Nx = last - Xoff;\n"
" } while (last > 0);\n"
"}\n";
valueOfTok(code, "last");
}
void valueFlowHang() {