Fixed #3428 (false negative: array bounds errors not found when duplicate class names present)
This commit is contained in:
parent
2bb5de4c89
commit
1ba1be4b8d
|
@ -1405,18 +1405,6 @@ void CheckBufferOverrun::checkStructVariable()
|
||||||
if (!scope->isClassOrStruct())
|
if (!scope->isClassOrStruct())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// are there duplicate names for classes/structs?
|
|
||||||
bool duplicateNames = false;
|
|
||||||
for (std::list<Scope>::const_iterator scope2 = symbolDatabase->scopeList.begin(); scope2 != symbolDatabase->scopeList.end(); ++scope2) {
|
|
||||||
if (scope2 != scope && scope2->isClassOrStruct() && scope2->className == scope->className) {
|
|
||||||
duplicateNames = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: handle duplicate names better (TestBufferOverrun::array_index_41)
|
|
||||||
if (duplicateNames)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// check all variables to see if they are arrays
|
// check all variables to see if they are arrays
|
||||||
std::list<Variable>::const_iterator var;
|
std::list<Variable>::const_iterator var;
|
||||||
for (var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
for (var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
||||||
|
@ -1433,6 +1421,13 @@ void CheckBufferOverrun::checkStructVariable()
|
||||||
if (func_scope->type != Scope::eFunction)
|
if (func_scope->type != Scope::eFunction)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// If struct is declared in a function then check
|
||||||
|
// if scope_func matches
|
||||||
|
if (scope->nestedIn->type == Scope::eFunction &&
|
||||||
|
scope->nestedIn != &*func_scope) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// check for member variables
|
// check for member variables
|
||||||
if (func_scope->functionOf == &*scope) {
|
if (func_scope->functionOf == &*scope) {
|
||||||
// only check non-empty function
|
// only check non-empty function
|
||||||
|
|
Loading…
Reference in New Issue