diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 90fcb1c4d..d92ed4654 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1405,18 +1405,6 @@ void CheckBufferOverrun::checkStructVariable() if (!scope->isClassOrStruct()) continue; - // are there duplicate names for classes/structs? - bool duplicateNames = false; - for (std::list::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 std::list::const_iterator var; for (var = scope->varlist.begin(); var != scope->varlist.end(); ++var) { @@ -1433,6 +1421,13 @@ void CheckBufferOverrun::checkStructVariable() if (func_scope->type != Scope::eFunction) 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 if (func_scope->functionOf == &*scope) { // only check non-empty function