Fixed #8233 (FP uninitvar found in bash:lib/readline/display.c)

This commit is contained in:
Daniel Marjamäki 2017-11-06 10:28:07 +01:00
parent 8b384f8ee5
commit 4a9984d73b
2 changed files with 22 additions and 1 deletions

View File

@ -1595,7 +1595,7 @@ static bool valueFlowForward(Token * const startToken,
errorLogger,
settings);
if (isVariableChanged(startToken1, startToken1->link(), varid, var->isGlobal(), settings)) {
if (!condAlwaysFalse && isVariableChanged(startToken1, startToken1->link(), varid, var->isGlobal(), settings)) {
removeValues(values, truevalues);
std::list<ValueFlow::Value>::iterator it;
@ -1626,6 +1626,14 @@ static bool valueFlowForward(Token * const startToken,
errorLogger,
settings);
if (!condAlwaysTrue && isVariableChanged(startTokenElse, startTokenElse->link(), varid, var->isGlobal(), settings)) {
removeValues(values, falsevalues);
std::list<ValueFlow::Value>::iterator it;
for (it = values.begin(); it != values.end(); ++it)
it->changeKnownToPossible();
}
// goto '}'
tok2 = startTokenElse->link();

View File

@ -2730,6 +2730,19 @@ private:
"}";
values = tokenValues(code, "n ==");
ASSERT_EQUALS(true, values.size() != 1U || !values.front().isUninitValue());
// #8233
code = "void foo() {\n"
" int x;\n"
" int y = 1;\n"
" if (y>1)\n"
" x = 1;\n"
" else\n"
" x = 1;\n"
" if (x>1) {}\n"
"}";
values = tokenValues(code, "x >");
ASSERT_EQUALS(true, values.size() == 1U && values.front().isIntValue());
}
};