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