File tree Expand file tree Collapse file tree
csharp/ql/test/library-tests/dataflow/fields Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ static void NotASetter(S s, object o)
1717 s . Field = o ;
1818 }
1919
20- private void M ( )
20+ private void M1 ( )
2121 {
2222 var o = Source < object > ( 1 ) ;
2323 var s = CreateS ( o ) ;
@@ -28,6 +28,35 @@ private void M()
2828 Sink ( s . Field ) ; // no flow
2929 }
3030
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+
3160 public static void Sink ( object o ) { }
3261
3362 static T Source < T > ( object source ) => throw null ;
Original file line number Diff line number Diff line change 11testFailures
2+ | E.cs:57:30:57:48 | // ... | Missing result:hasValueFlow=2 |
23edges
34| A.cs:5:17:5:28 | call to method Source<C> : C | A.cs:6:24:6:24 | access to local variable c : C |
45| 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