Code cleanup. Removed CheckLeakAutoVar::doubleDeallocationError since the same checking is already done by CheckOther::checkDoubleFree
This commit is contained in:
parent
fa2bca1e09
commit
2481b80875
|
@ -83,11 +83,6 @@ void CheckLeakAutoVar::deallocReturnError(const Token *tok, const std::string &v
|
||||||
reportError(tok, Severity::error, "newdeallocret", "Returning/using deallocated pointer " + varname);
|
reportError(tok, Severity::error, "newdeallocret", "Returning/using deallocated pointer " + varname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckLeakAutoVar::doubleDeallocationError(const Token *tok, const std::string &varname)
|
|
||||||
{
|
|
||||||
reportError(tok, Severity::error, "doubledeallocation", "Double deallocation: " + varname);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &functionName)
|
void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &functionName)
|
||||||
{
|
{
|
||||||
if (((!cfgalloc.empty() || !cfgdealloc.empty()) && _settings->isEnabled("style")) || _settings->experimental) {
|
if (((!cfgalloc.empty() || !cfgdealloc.empty()) && _settings->isEnabled("style")) || _settings->experimental) {
|
||||||
|
@ -425,7 +420,7 @@ void CheckLeakAutoVar::functionCall(const Token *tok, VarInfo *varInfo, const st
|
||||||
// possible usage
|
// possible usage
|
||||||
possibleUsage[arg->varId()] = tok->str();
|
possibleUsage[arg->varId()] = tok->str();
|
||||||
} else if (var->second == "dealloc") {
|
} else if (var->second == "dealloc") {
|
||||||
doubleDeallocationError(tok, arg->str());
|
// double deallocation is reported by CheckOther::checkDoubleFree
|
||||||
} else if (var->second != dealloc) {
|
} else if (var->second != dealloc) {
|
||||||
// mismatching allocation and deallocation
|
// mismatching allocation and deallocation
|
||||||
mismatchError(tok, arg->str());
|
mismatchError(tok, arg->str());
|
||||||
|
|
|
@ -110,7 +110,6 @@ private:
|
||||||
void mismatchError(const Token* tok, const std::string &varname);
|
void mismatchError(const Token* tok, const std::string &varname);
|
||||||
void deallocUseError(const Token *tok, const std::string &varname);
|
void deallocUseError(const Token *tok, const std::string &varname);
|
||||||
void deallocReturnError(const Token *tok, const std::string &varname);
|
void deallocReturnError(const Token *tok, const std::string &varname);
|
||||||
void doubleDeallocationError(const Token *tok, const std::string &varname);
|
|
||||||
|
|
||||||
/** message: user configuration is needed to complete analysis */
|
/** message: user configuration is needed to complete analysis */
|
||||||
void configurationInfo(const Token* tok, const std::string &functionName);
|
void configurationInfo(const Token* tok, const std::string &functionName);
|
||||||
|
@ -120,7 +119,6 @@ private:
|
||||||
c.leakError(NULL, "p");
|
c.leakError(NULL, "p");
|
||||||
c.mismatchError(NULL, "p");
|
c.mismatchError(NULL, "p");
|
||||||
c.deallocUseError(NULL, "p");
|
c.deallocUseError(NULL, "p");
|
||||||
c.doubleDeallocationError(NULL, "p");
|
|
||||||
c.configurationInfo(0, "f"); // user configuration is needed to complete analysis
|
c.configurationInfo(0, "f"); // user configuration is needed to complete analysis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,6 @@ private:
|
||||||
TEST_CASE(deallocuse3);
|
TEST_CASE(deallocuse3);
|
||||||
TEST_CASE(deallocuse4);
|
TEST_CASE(deallocuse4);
|
||||||
|
|
||||||
TEST_CASE(doublefree);
|
|
||||||
|
|
||||||
// exit
|
// exit
|
||||||
TEST_CASE(exit1);
|
TEST_CASE(exit1);
|
||||||
TEST_CASE(exit2);
|
TEST_CASE(exit2);
|
||||||
|
@ -241,14 +239,6 @@ private:
|
||||||
ASSERT_EQUALS("[test.c:3]: (error) Returning/using deallocated pointer p\n", errout.str());
|
ASSERT_EQUALS("[test.c:3]: (error) Returning/using deallocated pointer p\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void doublefree() {
|
|
||||||
check("void f(char *p) {\n"
|
|
||||||
" free(p);\n"
|
|
||||||
" free(p);\n"
|
|
||||||
"}");
|
|
||||||
ASSERT_EQUALS("[test.c:3]: (error) Double deallocation: p\n", errout.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void exit1() {
|
void exit1() {
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" char *p = malloc(10);\n"
|
" char *p = malloc(10);\n"
|
||||||
|
|
Loading…
Reference in New Issue