Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fdd8de7 commit e419ea0Copy full SHA for e419ea0
1 file changed
cpp/ql/test/library-tests/dataflow/fields/struct_init.c
@@ -0,0 +1,38 @@
1
+void sink(void *o);
2
+void *user_input(void);
3
+
4
+struct AB {
5
+ void *a;
6
+ void *b;
7
+};
8
9
+struct Outer {
10
+ struct AB nestedAB;
11
+ struct AB *pointerAB;
12
13
14
+void absink(struct AB *ab) {
15
+ sink(ab->a); // flow x3 [NOT DETECTED]
16
+ sink(ab->b); // no flow
17
+}
18
19
+int struct_init(void) {
20
+ struct AB ab = { user_input(), 0 };
21
22
+ sink(ab.a); // flow [NOT DETECTED]
23
+ sink(ab.b); // no flow
24
+ absink(&ab);
25
26
+ struct Outer outer = {
27
+ { user_input(), 0 },
28
+ &ab,
29
+ };
30
31
+ sink(outer.nestedAB.a); // flow [NOT DETECTED]
32
+ sink(outer.nestedAB.b); // no flow
33
+ sink(outer.pointerAB->a); // flow [NOT DETECTED]
34
+ sink(outer.pointerAB->b); // no flow
35
36
+ absink(&outer.nestedAB);
37
+ absink(outer.pointerAB);
38
0 commit comments