memory leak: fixed issue with reporting wrong location
This commit is contained in:
parent
d4ecddd53c
commit
87b0314e72
|
@ -1447,14 +1447,16 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_ParseClass(const Token *
|
||||||
if (tok->isName() || Token::Match(tok, "[;}]"))
|
if (tok->isName() || Token::Match(tok, "[;}]"))
|
||||||
{
|
{
|
||||||
if (_settings._showAll || !isclass(tok->tokAt(1)))
|
if (_settings._showAll || !isclass(tok->tokAt(1)))
|
||||||
CheckMemoryLeak_ClassMembers_Variable(classname, tok->strAt(3));
|
CheckMemoryLeak_ClassMembers_Variable(classname, tok->tokAt(3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_Variable(const std::vector<const char *> &classname, const char varname[])
|
void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_Variable(const std::vector<const char *> &classname, const Token *tokVarname)
|
||||||
{
|
{
|
||||||
|
const char *varname = tokVarname->strAt(0);
|
||||||
|
|
||||||
// Function pattern.. Check if member function
|
// Function pattern.. Check if member function
|
||||||
std::ostringstream fpattern;
|
std::ostringstream fpattern;
|
||||||
for (unsigned int i = 0; i < classname.size(); i++)
|
for (unsigned int i = 0; i < classname.size(); i++)
|
||||||
|
@ -1560,7 +1562,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_ClassMembers_Variable(const std::vect
|
||||||
|
|
||||||
if (Alloc != No && Dealloc == No)
|
if (Alloc != No && Dealloc == No)
|
||||||
{
|
{
|
||||||
MemoryLeak(_tokenizer->tokens(), FullVariableName.str().c_str(), Alloc, true);
|
MemoryLeak(tokVarname, FullVariableName.str().c_str(), Alloc, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void CheckMemoryLeak_ClassMembers_Variable(const std::vector<const char *> &classname, const char varname[]);
|
void CheckMemoryLeak_ClassMembers_Variable(const std::vector<const char *> &classname, const Token *tokVarname);
|
||||||
void CheckMemoryLeak_ClassMembers_ParseClass(const Token *tok1, std::vector<const char *> &classname);
|
void CheckMemoryLeak_ClassMembers_ParseClass(const Token *tok1, std::vector<const char *> &classname);
|
||||||
void CheckMemoryLeak_ClassMembers();
|
void CheckMemoryLeak_ClassMembers();
|
||||||
void CheckMemoryLeak_InFunction();
|
void CheckMemoryLeak_InFunction();
|
||||||
|
|
|
@ -1327,7 +1327,7 @@ private:
|
||||||
" delete [] str2;\n"
|
" delete [] str2;\n"
|
||||||
"}\n", true);
|
"}\n", true);
|
||||||
|
|
||||||
ASSERT_EQUALS(std::string("[test.cpp:1]: (all) Memory leak: Fred::str1\n"), errout.str());
|
ASSERT_EQUALS(std::string("[test.cpp:4]: (all) Memory leak: Fred::str1\n"), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue