Skip to content

Commit 8304545

Browse files
fixup! Fix #8260 Improve check: Pointer calculation result not null
1 parent f4b877b commit 8304545

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/valueflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett
11781178
const Token* op1 = tok->astOperand1();
11791179
const Token* op2 = tok->astOperand2();
11801180
if ((op1 && op1->hasKnownIntValue() && op1->getKnownIntValue() != 0)
1181-
|| (op2 && op2->hasKnownIntValue() && op2->getKnownIntValue() != 0)) {
1181+
|| (op2 && op2->hasKnownIntValue() && op2->getKnownIntValue() != 0)) {
11821182
ValueFlow::Value val(0);
11831183
val.setImpossible();
11841184
val.errorPath.emplace_back(tok, "Pointer arithmetic result cannot be null");

test/testcondition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6246,7 +6246,7 @@ class TestCondition : public TestFixture {
62466246
" if (q);\n"
62476247
"}");
62486248
ASSERT_EQUALS("[test.cpp:3:7]: (warning) Comparison is wrong. Result of 'q' can't be 0 unless there is pointer overflow, and pointer overflow is undefined behaviour. [pointerAdditionResultNotNull]\n", errout_str());
6249-
}
6249+
}
62506250

62516251
void duplicateConditionalAssign() {
62526252
setMultiline();

0 commit comments

Comments
 (0)