File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
csharp/ql/test/library-tests/dataflow/fields Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ static void NotASetter(S s, object o)
17
17
s . Field = o ;
18
18
}
19
19
20
- private void M ( )
20
+ private void M1 ( )
21
21
{
22
22
var o = Source < object > ( 1 ) ;
23
23
var s = CreateS ( o ) ;
@@ -28,6 +28,35 @@ private void M()
28
28
Sink ( s . Field ) ; // no flow
29
29
}
30
30
31
+ ref struct RefS
32
+ {
33
+ public object Field ;
34
+ public ref object RefField ;
35
+
36
+ public RefS ( object o1 , ref object o2 )
37
+ {
38
+ Field = o1 ;
39
+ RefField = ref o2 ;
40
+ }
41
+ }
42
+
43
+ static void PartialSetter ( RefS s , object o )
44
+ {
45
+ s . Field = o ;
46
+ s . RefField = o ;
47
+ }
48
+
49
+ private void M2 ( )
50
+ {
51
+ var o1 = new object ( ) ;
52
+ var o2 = new object ( ) ;
53
+ var refs = new RefS ( o1 , ref o2 ) ;
54
+ var taint = Source < object > ( 2 ) ;
55
+ PartialSetter ( refs , taint ) ;
56
+ Sink ( refs . Field ) ; // no flow
57
+ Sink ( refs . RefField ) ; // $ hasValueFlow=2
58
+ }
59
+
31
60
public static void Sink ( object o ) { }
32
61
33
62
static T Source < T > ( object source ) => throw null ;
Original file line number Diff line number Diff line change 1
1
testFailures
2
+ | E.cs:57:30:57:48 | // ... | Missing result:hasValueFlow=2 |
2
3
edges
3
4
| A.cs:5:17:5:28 | call to method Source<C> : C | A.cs:6:24:6:24 | access to local variable c : C |
4
5
| A.cs:5:17:5:28 | call to method Source<C> : C | A.cs:6:24:6:24 | access to local variable c : C |
You can’t perform that action at this time.
0 commit comments