Fix 10665: Crash in ExpressionAnalyzer (#3661)

This commit is contained in:
Paul Fultz II 2022-01-02 01:09:23 -06:00 committed by GitHub
parent 4b04c86249
commit 50862d1ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -5100,6 +5100,10 @@ static void valueFlowAfterSwap(TokenList* tokenlist,
std::vector<Token*> args = astFlatten(tok->next()->astOperand2(), ",");
if (args.size() != 2)
continue;
if (args[0]->exprId() == 0)
continue;
if (args[1]->exprId() == 0)
continue;
for (int i = 0; i < 2; i++) {
std::vector<const Variable*> vars = getVariables(args[0]);
std::list<ValueFlow::Value> values = args[0]->values();

View File

@ -6330,6 +6330,14 @@ private:
" && ch != '\\\'' && ch != '\\\"');\n"
"}\n";
valueOfTok(code, "return");
code = "void heapSort() {\n"
" int n = m_size;\n"
" while (n >= 1) {\n"
" swap(0, n - 1);\n"
" }\n"
"}\n";
valueOfTok(code, "swap");
}
void valueFlowCrashConstructorInitialization() { // #9577