Fix FP mismatchAllocDealloc, uninitdata for new with initializer (#5106)
This commit is contained in:
parent
9810bad869
commit
52c0f10fa1
|
@ -417,7 +417,7 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
changeAllocStatusIfRealloc(alloctype, fTok, varTok);
|
||||
} else if (mTokenizer->isCPP() && Token::Match(varTok->tokAt(2), "new !!(")) {
|
||||
const Token* tok2 = varTok->tokAt(2)->astOperand1();
|
||||
const bool arrayNew = (tok2 && (tok2->str() == "[" || (tok2->str() == "(" && tok2->astOperand1() && tok2->astOperand1()->str() == "[")));
|
||||
const bool arrayNew = (tok2 && (tok2->str() == "[" || (Token::Match(tok2, "(|{") && tok2->astOperand1() && tok2->astOperand1()->str() == "[")));
|
||||
VarInfo::AllocInfo& varAlloc = alloctype[varTok->varId()];
|
||||
varAlloc.type = arrayNew ? NEW_ARRAY : NEW;
|
||||
varAlloc.status = VarInfo::ALLOC;
|
||||
|
|
|
@ -2101,6 +2101,12 @@ private:
|
|||
" }\n"
|
||||
"}\n", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(int i) {\n"
|
||||
" int* a = new int[i] {};\n"
|
||||
" delete[] a;\n"
|
||||
"}\n", /*cpp*/ true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void smartPointerDeleter() {
|
||||
|
|
Loading…
Reference in New Issue