Skip to content

Commit 53299d6

Browse files
committed
C++: Add more tests.
1 parent c8f9401 commit 53299d6

File tree

1 file changed

+16
-0
lines changed
  • cpp/ql/test/query-tests/Likely Bugs/Memory Management/UsingExpiredStackAddress

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,19 @@ void test_escape_through_arrays() {
181181
int x18 = s5.pp[0][0]; // BAD
182182
int x19 = (*s6.pp)[0]; // BAD
183183
}
184+
185+
void not_escape_through_arrays() {
186+
int x;
187+
188+
s1.a1[0] = x;
189+
s1.a2[0][1] = s1.a1[0];
190+
**s1.a3[0] = 42;
191+
}
192+
193+
void test_not_escape_through_array() {
194+
not_escape_through_arrays();
195+
196+
int x20 = s1.a1[0]; // GOOD
197+
int x21 = s1.a2[0][1]; // GOOD
198+
int* x22 = s1.a3[5][2]; // GOOD
199+
}

0 commit comments

Comments
 (0)