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

Method argumentSizeError

lib/checkbufferoverrun.cpp:872–886  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

870}
871
872void CheckBufferOverrunImpl::argumentSizeError(const Token *tok, const std::string &functionName, nonneg int paramIndex, const std::string &paramExpression, const Variable *paramVar, const Variable *functionArg)
873{
874 const std::string strParamNum = std::to_string(paramIndex + 1) + getOrdinalText(paramIndex + 1);
875 ErrorPath errorPath;
876 errorPath.emplace_back(tok, "Function '" + functionName + "' is called");
877 if (functionArg)
878 errorPath.emplace_back(functionArg->nameToken(), "Declaration of " + strParamNum + " function argument.");
879 if (paramVar)
880 errorPath.emplace_back(paramVar->nameToken(), "Passing buffer '" + paramVar->name() + "' to function that is declared here");
881 errorPath.emplace_back(tok, "");
882
883 reportError(std::move(errorPath), Severity::warning, "argumentSize",
884 "$symbol:" + functionName + '\n' +
885 "Buffer '" + paramExpression + "' is too small, the function '" + functionName + "' expects a bigger buffer in " + strParamNum + " argument", CWE_ARGUMENT_SIZE, Certainty::normal);
886}
887
888//---------------------------------------------------------------------------
889// CTU..

Callers 1

getErrorMessagesMethod · 0.80

Calls 4

getOrdinalTextFunction · 0.85
reportErrorFunction · 0.70
nameTokenMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected