Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0df3d2c

Browse files
committed
[zlaski/pointer-overflow-check] Improve test case.
1 parent 3aafcf4 commit 0df3d2c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • cpp/ql/test/query-tests/Likely Bugs/Memory Management/PointerOverflowCheck

cpp/ql/test/query-tests/Likely Bugs/Memory Management/PointerOverflowCheck/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bool check_pointer_overflow(P *ptr, P *ptr_end) {
99
// x86-64 gcc 9.2 -O2: not deleted
1010
// x86-64 clang 9.0.0 -O2: not deleted
1111
// x64 msvc v19.22 /O2: not deleted
12-
return ptr + 4 >= ptr_end; // GOOD
12+
return ptr_end - ptr > 4; // GOOD
1313
}
1414

1515
struct Q {
@@ -22,6 +22,6 @@ struct Q {
2222
void foo(int untrusted_int) {
2323
Q q;
2424
if (q.begin() + untrusted_int > q.end() || // GOOD
25-
q.begin() + untrusted_int < q.begin()) // BAD
25+
q.begin() + untrusted_int < q.begin()) // BAD [NOT DETECTED]
2626
throw q;
2727
}

0 commit comments

Comments
 (0)