GeezerVison is showing github.com — Fix crashes in z3 · Ken-Patrick/cppcheck@172cd2d
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/checkstl.cpp +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2036,6 +2036,8 @@ static const Token *singleMemberCallInScope(const Token *start, nonneg int varid |
2036 | 2036 | if (!Token::findmatch(dotTok->tokAt(2), "%varid%", endStatement, varid)) |
2037 | 2037 | return nullptr; |
2038 | 2038 | input = Token::Match(start->next(), "%var% . %name% ( %varid% )", varid); |
| 2039 | + if (!dotTok->astOperand1()) // incomplete code |
| 2040 | + return nullptr; |
2039 | 2041 | if (isVariableChanged(dotTok->next(), endStatement, dotTok->astOperand1()->varId(), false, nullptr, true)) |
2040 | 2042 | return nullptr; |
2041 | 2043 | return dotTok; |
|
Collapse file
Copy file name to clipboardExpand all lines: test/teststl.cpp +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3241,6 +3241,20 @@ class TestStl : public TestFixture { |
3241 | 3241 | " void shift() { EffectivityRangeData<int>::iterator it; } \n" |
3242 | 3242 | "};\n"); |
3243 | 3243 | ASSERT_EQUALS("", errout.str()); |
| 3244 | + |
| 3245 | + // test for crash in z3 |
| 3246 | + check("struct explain::imp {\n" |
| 3247 | + " solver &m_solver;\n" |
| 3248 | + "\n" |
| 3249 | + " void project(var x, unsigned num, literal const *ls,\n" |
| 3250 | + " const scoped_literal_vector &result) {\n" |
| 3251 | + " DEBUG_CODE(TRACE(\"nlsat\",\n" |
| 3252 | + " for (literal l\n" |
| 3253 | + " : result) { m_solver.display(tout << \" \", l); });\n" |
| 3254 | + " );\n" |
| 3255 | + " }\n" |
| 3256 | + "};"); |
| 3257 | + ASSERT_EQUALS("", errout.str()); |
3244 | 3258 | } |
3245 | 3259 |
|
3246 | 3260 | void dereferenceInvalidIterator() { |
|