Skip to content

Commit b9c933f

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

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
@@ -1183,7 +1183,7 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett
11831183
const Token* op1 = tok->astOperand1();
11841184
const Token* op2 = tok->astOperand2();
11851185
if ((op1 && op1->hasKnownIntValue() && op1->getKnownIntValue() != 0)
1186-
|| (op2 && op2->hasKnownIntValue() && op2->getKnownIntValue() != 0)) {
1186+
|| (op2 && op2->hasKnownIntValue() && op2->getKnownIntValue() != 0)) {
11871187
ValueFlow::Value val(0);
11881188
val.setImpossible();
11891189
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
@@ -6141,7 +6141,7 @@ class TestCondition : public TestFixture {
61416141
" if (q);\n"
61426142
"}");
61436143
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());
6144-
}
6144+
}
61456145

61466146
void duplicateConditionalAssign() {
61476147
setMultiline();

0 commit comments

Comments
 (0)