parent
0561877182
commit
8c2a5c9813
|
@ -198,9 +198,9 @@ static bool isPointerReleased(const Token *startToken, const Token *endToken, un
|
||||||
for (const Token *tok = startToken; tok && tok != endToken; tok = tok->next()) {
|
for (const Token *tok = startToken; tok && tok != endToken; tok = tok->next()) {
|
||||||
if (tok->varId() != varid)
|
if (tok->varId() != varid)
|
||||||
continue;
|
continue;
|
||||||
if(Token::Match(tok, "%var% . release ( )"))
|
if (Token::Match(tok, "%var% . release ( )"))
|
||||||
return true;
|
return true;
|
||||||
if(Token::Match(tok, "%var% ="))
|
if (Token::Match(tok, "%var% ="))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -581,7 +581,7 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
|
||||||
tok = typeEndTok->linkAt(2);
|
tok = typeEndTok->linkAt(2);
|
||||||
|
|
||||||
unsigned varid = typeEndTok->next()->varId();
|
unsigned varid = typeEndTok->next()->varId();
|
||||||
if(isPointerReleased(typeEndTok->tokAt(2), endToken, varid))
|
if (isPointerReleased(typeEndTok->tokAt(2), endToken, varid))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool arrayDelete = false;
|
bool arrayDelete = false;
|
||||||
|
|
|
@ -1723,15 +1723,15 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
Token * const startToken1 = tok2->linkAt(1)->next();
|
Token * const startToken1 = tok2->linkAt(1)->next();
|
||||||
|
|
||||||
bool vfresult = valueFlowForward(startToken1->next(),
|
bool vfresult = valueFlowForward(startToken1->next(),
|
||||||
startToken1->link(),
|
startToken1->link(),
|
||||||
var,
|
var,
|
||||||
varid,
|
varid,
|
||||||
truevalues,
|
truevalues,
|
||||||
constValue,
|
constValue,
|
||||||
subFunction,
|
subFunction,
|
||||||
tokenlist,
|
tokenlist,
|
||||||
errorLogger,
|
errorLogger,
|
||||||
settings);
|
settings);
|
||||||
|
|
||||||
if (!condAlwaysFalse && isVariableChanged(startToken1, startToken1->link(), varid, var->isGlobal(), settings, tokenlist->isCPP())) {
|
if (!condAlwaysFalse && isVariableChanged(startToken1, startToken1->link(), varid, var->isGlobal(), settings, tokenlist->isCPP())) {
|
||||||
removeValues(values, truevalues);
|
removeValues(values, truevalues);
|
||||||
|
@ -1751,15 +1751,15 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
Token * const startTokenElse = tok2->tokAt(2);
|
Token * const startTokenElse = tok2->tokAt(2);
|
||||||
|
|
||||||
vfresult = valueFlowForward(startTokenElse->next(),
|
vfresult = valueFlowForward(startTokenElse->next(),
|
||||||
startTokenElse->link(),
|
startTokenElse->link(),
|
||||||
var,
|
var,
|
||||||
varid,
|
varid,
|
||||||
falsevalues,
|
falsevalues,
|
||||||
constValue,
|
constValue,
|
||||||
subFunction,
|
subFunction,
|
||||||
tokenlist,
|
tokenlist,
|
||||||
errorLogger,
|
errorLogger,
|
||||||
settings);
|
settings);
|
||||||
|
|
||||||
if (!condAlwaysTrue && isVariableChanged(startTokenElse, startTokenElse->link(), varid, var->isGlobal(), settings, tokenlist->isCPP())) {
|
if (!condAlwaysTrue && isVariableChanged(startTokenElse, startTokenElse->link(), varid, var->isGlobal(), settings, tokenlist->isCPP())) {
|
||||||
removeValues(values, falsevalues);
|
removeValues(values, falsevalues);
|
||||||
|
|
|
@ -1780,18 +1780,18 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void array_index_negative3() {
|
void array_index_negative3() {
|
||||||
check("int f(int i) {\n"
|
check("int f(int i) {\n"
|
||||||
" int p[2] = {0, 0};\n"
|
" int p[2] = {0, 0};\n"
|
||||||
" if(i >= 2)\n"
|
" if(i >= 2)\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
" else if(i == 0)\n"
|
" else if(i == 0)\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
" return p[i - 1];\n"
|
" return p[i - 1];\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"void g(int i) {\n"
|
"void g(int i) {\n"
|
||||||
" if( i == 0 )\n"
|
" if( i == 0 )\n"
|
||||||
" return f(i);\n"
|
" return f(i);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue