Skip to content

Commit cd4ec6c

Browse files
committed
C++: Add FN testcase.
1 parent 3767ce5 commit cd4ec6c

File tree

1 file changed

+14
-1
lines changed
  • cpp/ql/test/experimental/query-tests/Security/CWE/CWE-193/pointer-deref

1 file changed

+14
-1
lines changed

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-193/pointer-deref/test.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,4 +700,17 @@ void test34(unsigned size) {
700700
if (p + 1 < end) {
701701
int val = *p; // GOOD
702702
}
703-
}
703+
}
704+
705+
void deref(char* q) {
706+
char x = *q; // $ MISSING: deref=L712->L706 deref=L713->L706
707+
}
708+
709+
void test35(unsigned long size, char* q)
710+
{
711+
char* p = new char[size];
712+
char* end = p + size; // $ alloc=L711
713+
if(q <= end) {
714+
deref(q);
715+
}
716+
}

0 commit comments

Comments
 (0)