Fixed #8617 (False positive: uninitdata for memory allocated and initialized in function called new (C code))
This commit is contained in:
parent
8c8952ae7c
commit
c3ae028a41
|
@ -720,7 +720,7 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (var.isPointer() && (var.typeStartToken()->isStandardType() || var.typeStartToken()->isEnumType() || (var.type() && var.type()->needInitialization == Type::NeedInitialization::True)) && Token::simpleMatch(tok->next(), "= new")) {
|
if (mTokenizer->isCPP() && var.isPointer() && (var.typeStartToken()->isStandardType() || var.typeStartToken()->isEnumType() || (var.type() && var.type()->needInitialization == Type::NeedInitialization::True)) && Token::simpleMatch(tok->next(), "= new")) {
|
||||||
*alloc = CTOR_CALL;
|
*alloc = CTOR_CALL;
|
||||||
|
|
||||||
// type has constructor(s)
|
// type has constructor(s)
|
||||||
|
|
|
@ -1719,6 +1719,12 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// new in C code does not allocate..
|
||||||
|
checkUninitVar("int main() {\n"
|
||||||
|
" char * pBuf = new(10);\n"
|
||||||
|
" a = *pBuf;\n"
|
||||||
|
"}", "test.c");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// class / struct..
|
// class / struct..
|
||||||
|
|
Loading…
Reference in New Issue