MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / unsafeArgAllocError

Method unsafeArgAllocError

lib/checkmemoryleak.cpp:1211–1219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1209}
1210
1211void CheckMemoryLeakNoVarImpl::unsafeArgAllocError(const Token *tok, const std::string &funcName, const std::string &ptrType, const std::string& objType)
1212{
1213 const std::string factoryFunc = ptrType == "shared_ptr" ? "make_shared" : "make_unique";
1214 reportError(tok, Severity::warning, "leakUnsafeArgAlloc",
1215 "$symbol:" + funcName + "\n"
1216 "Unsafe allocation. If $symbol() throws, memory could be leaked. Use " + factoryFunc + "<" + objType + ">() instead.",
1217 CWE401,
1218 Certainty::inconclusive); // Inconclusive because funcName may never throw
1219}
1220
1221void CheckMemoryLeakNoVar::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
1222{

Callers 1

getErrorMessagesMethod · 0.80

Calls 1

reportErrorFunction · 0.70

Tested by

no test coverage detected