Skip to content

Commit ec4f0cc

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

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
@@ -6260,7 +6260,7 @@ class TestCondition : public TestFixture {
62606260
" if (q);\n"
62616261
"}");
62626262
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());
6263-
}
6263+
}
62646264

62656265
void duplicateConditionalAssign() {
62666266
setMultiline();

0 commit comments

Comments
 (0)