Fixed #3993 (Resource also reported as memory leak)
This commit is contained in:
parent
9fd127617e
commit
9a7d09086e
|
@ -64,10 +64,13 @@ void VarInfo::possibleUsageAll(const std::string &functionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname)
|
void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname, const std::string &type)
|
||||||
{
|
{
|
||||||
const Standards standards;
|
const Standards standards;
|
||||||
CheckMemoryLeak checkmemleak(_tokenizer, _errorLogger, standards);
|
CheckMemoryLeak checkmemleak(_tokenizer, _errorLogger, standards);
|
||||||
|
if (type == "fopen")
|
||||||
|
checkmemleak.resourceLeakError(tok, varname);
|
||||||
|
else
|
||||||
checkmemleak.memleakError(tok, varname);
|
checkmemleak.memleakError(tok, varname);
|
||||||
//reportError(tok, Severity::error, "newleak", "New memory leak: " + varname);
|
//reportError(tok, Severity::error, "newleak", "New memory leak: " + varname);
|
||||||
}
|
}
|
||||||
|
@ -523,7 +526,7 @@ void CheckLeakAutoVar::leakIfAllocated(const Token *vartok,
|
||||||
if (var != alloctype.end() && var->second != "dealloc") {
|
if (var != alloctype.end() && var->second != "dealloc") {
|
||||||
const std::map<unsigned int, std::string>::const_iterator use = possibleUsage.find(vartok->varId());
|
const std::map<unsigned int, std::string>::const_iterator use = possibleUsage.find(vartok->varId());
|
||||||
if (use == possibleUsage.end()) {
|
if (use == possibleUsage.end()) {
|
||||||
leakError(vartok, vartok->str());
|
leakError(vartok, vartok->str(), var->second);
|
||||||
} else {
|
} else {
|
||||||
configurationInfo(vartok, use->second);
|
configurationInfo(vartok, use->second);
|
||||||
}
|
}
|
||||||
|
@ -566,7 +569,7 @@ void CheckLeakAutoVar::ret(const Token *tok, const VarInfo &varInfo)
|
||||||
|
|
||||||
const std::map<unsigned int, std::string>::const_iterator use = possibleUsage.find(varid);
|
const std::map<unsigned int, std::string>::const_iterator use = possibleUsage.find(varid);
|
||||||
if (use == possibleUsage.end()) {
|
if (use == possibleUsage.end()) {
|
||||||
leakError(tok, var->name());
|
leakError(tok, var->name(), it->second);
|
||||||
} else {
|
} else {
|
||||||
configurationInfo(tok, use->second);
|
configurationInfo(tok, use->second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ private:
|
||||||
/** if variable is allocated then there is a leak */
|
/** if variable is allocated then there is a leak */
|
||||||
void leakIfAllocated(const Token *vartok, const VarInfo &varInfo);
|
void leakIfAllocated(const Token *vartok, const VarInfo &varInfo);
|
||||||
|
|
||||||
void leakError(const Token* tok, const std::string &varname);
|
void leakError(const Token* tok, const std::string &varname, const std::string &type);
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue