Skip to content

Commit 202e9dd

Browse files
committed
fix
1 parent f20469b commit 202e9dd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/valueflow.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7025,6 +7025,12 @@ static void valueFlowDynamicBufferSize(const TokenList& tokenlist, const SymbolD
70257025
auto getBufferSizeFromNew = [&](const Token* newTok) -> MathLib::bigint {
70267026
MathLib::bigint sizeValue = -1, numElem = -1;
70277027

7028+
// ::operator new(size_t size)
7029+
if (Token::Match(newTok->astOperand1(), "::| operatornew")) {
7030+
const Token *sizeTok = newTok->astOperand2();
7031+
return sizeTok->hasKnownIntValue() ? sizeTok->getKnownIntValue() : -1;
7032+
}
7033+
70287034
if (newTok && newTok->astOperand1()) { // number of elements
70297035
const Token* bracTok = nullptr, *typeTok = nullptr;
70307036
if (newTok->astOperand1()->str() == "[")
@@ -7071,7 +7077,7 @@ static void valueFlowDynamicBufferSize(const TokenList& tokenlist, const SymbolD
70717077
if (!rhs)
70727078
continue;
70737079

7074-
const bool isNew = rhs->isCpp() && rhs->str() == "new";
7080+
const bool isNew = rhs->isCpp() && (rhs->str() == "new" || Token::Match(rhs->astOperand1(), "::| operatornew"));
70757081
if (!isNew && !Token::Match(rhs->previous(), "%name% ("))
70767082
continue;
70777083

0 commit comments

Comments
 (0)