Skip to content

Commit 023b8e4

Browse files
committed
C++: Add a testcase that needs heuristic allocation.
1 parent 1a57f81 commit 023b8e4

File tree

1 file changed

+6
-0
lines changed
  • cpp/ql/test/experimental/query-tests/Security/CWE/CWE-119

1 file changed

+6
-0
lines changed

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-119/test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,9 @@ void test_flow_through_setter(unsigned size) {
243243
memset(str.string, 0, size + 1); // BAD
244244
}
245245

246+
void* my_alloc(unsigned size);
247+
248+
void foo(unsigned size) {
249+
int* p = (int*)my_alloc(size); // BAD [NOT DETECTED]
250+
memset(p, 0, size + 1);
251+
}

0 commit comments

Comments
 (0)