Merge pull request #13699 from MathiasVP/final-config-to-invalid-pointer-deref

C++: Handle call-contexts mismatches in `cpp/invalid-pointer-deref`
This commit is contained in:
Mathias Vorreiter Pedersen
2023-07-18 13:08:21 +01:00
committed by GitHub
3 changed files with 347 additions and 1571 deletions

View File

@@ -675,3 +675,18 @@ void test33(unsigned size, unsigned src_pos)
xs[dst_pos++] = 0; // GOOD [FALSE POSITIVE]
}
}
int* pointer_arithmetic(int *p, int offset) {
return p + offset;
}
void test_missing_call_context_1(unsigned size) {
int* p = new int[size];
int* end = pointer_arithmetic(p, size);
}
void test_missing_call_context_2(unsigned size) {
int* p = new int[size];
int* end_minus_one = pointer_arithmetic(p, size - 1);
*end_minus_one = '0'; // GOOD
}