Skip to content

Commit 86f361c

Browse files
committed
Fix #14980 Nullptr dereference in valueFlowDynamicBufferSize()
1 parent 2e19539 commit 86f361c

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/valueflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7077,7 +7077,7 @@ static void valueFlowDynamicBufferSize(const TokenList& tokenlist, const SymbolD
70777077
if (!rhs)
70787078
continue;
70797079

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

test/testvalueflow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8488,6 +8488,11 @@ class TestValueFlow : public TestFixture {
84888488
" };\n"
84898489
"}\n";
84908490
(void)valueOfTok(code, "E0");
8491+
8492+
code = "void f() {\n" // #14980
8493+
" OpNew *newp = &operator new;\n"
8494+
"}\n";
8495+
(void)valueOfTok(code, "&");
84918496
}
84928497

84938498
void valueFlowHang() {

0 commit comments

Comments
 (0)