Skip to content

Commit df1e215

Browse files
committed
C#: Add ?? as a local dataflow step.
1 parent 48c0d9e commit df1e215

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

csharp/ql/src/API Abuse/NoDisposeCallOnLocalIDisposable.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ private class Conf extends DataFlow::Configuration {
8181

8282
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
8383
node2.asExpr() = any(LocalScopeDisposableCreation other | other.getAnArgument() = node1.asExpr())
84-
or
85-
exists(NullCoalescingExpr nce | node1.asExpr() = nce.getRightOperand() and node2.asExpr() = nce)
8684
}
8785

8886
override predicate isBarrierOut(DataFlow::Node node) {

csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ module LocalFlow {
8686
scope = e2 and
8787
isSuccessor = true
8888
or
89+
e1 = e2.(NullCoalescingExpr).getAnOperand() and
90+
scope = e2 and
91+
isSuccessor = false
92+
or
8993
e1 = e2.(SuppressNullableWarningExpr).getExpr() and
9094
scope = e2 and
9195
isSuccessor = true

csharp/ql/test/library-tests/dataflow/local/DataFlow.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
| LocalDataFlow.cs:412:15:412:20 | access to local variable sink70 |
99
| LocalDataFlow.cs:420:19:420:24 | access to local variable sink71 |
1010
| LocalDataFlow.cs:430:23:430:28 | access to local variable sink72 |
11+
| LocalDataFlow.cs:445:15:445:20 | access to local variable sink73 |
12+
| LocalDataFlow.cs:446:15:446:20 | access to local variable sink74 |
1113
| LocalDataFlow.cs:472:15:472:21 | access to parameter tainted |
1214
| SSA.cs:9:15:9:22 | access to local variable ssaSink0 |
1315
| SSA.cs:25:15:25:22 | access to local variable ssaSink1 |

csharp/ql/test/library-tests/dataflow/local/DataFlowStep.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,15 @@
568568
| LocalDataFlow.cs:435:17:435:24 | access to local variable nonSink0 | LocalDataFlow.cs:443:22:443:29 | access to local variable nonSink0 |
569569
| LocalDataFlow.cs:437:18:437:33 | SSA def(nonSink17) | LocalDataFlow.cs:438:23:438:31 | access to local variable nonSink17 |
570570
| LocalDataFlow.cs:443:13:443:38 | SSA def(sink73) | LocalDataFlow.cs:445:15:445:20 | access to local variable sink73 |
571+
| LocalDataFlow.cs:443:22:443:29 | access to local variable nonSink0 | LocalDataFlow.cs:443:22:443:38 | ... ?? ... |
571572
| LocalDataFlow.cs:443:22:443:29 | access to local variable nonSink0 | LocalDataFlow.cs:444:31:444:38 | access to local variable nonSink0 |
572573
| LocalDataFlow.cs:443:22:443:38 | ... ?? ... | LocalDataFlow.cs:443:13:443:38 | SSA def(sink73) |
574+
| LocalDataFlow.cs:443:34:443:38 | access to local variable sink0 | LocalDataFlow.cs:443:22:443:38 | ... ?? ... |
573575
| LocalDataFlow.cs:443:34:443:38 | access to local variable sink0 | LocalDataFlow.cs:444:22:444:26 | access to local variable sink0 |
574576
| LocalDataFlow.cs:444:13:444:38 | SSA def(sink74) | LocalDataFlow.cs:446:15:446:20 | access to local variable sink74 |
577+
| LocalDataFlow.cs:444:22:444:26 | access to local variable sink0 | LocalDataFlow.cs:444:22:444:38 | ... ?? ... |
575578
| LocalDataFlow.cs:444:22:444:38 | ... ?? ... | LocalDataFlow.cs:444:13:444:38 | SSA def(sink74) |
579+
| LocalDataFlow.cs:444:31:444:38 | access to local variable nonSink0 | LocalDataFlow.cs:444:22:444:38 | ... ?? ... |
576580
| LocalDataFlow.cs:464:28:464:30 | this | LocalDataFlow.cs:464:41:464:45 | this access |
577581
| LocalDataFlow.cs:464:50:464:52 | this | LocalDataFlow.cs:464:56:464:60 | this access |
578582
| LocalDataFlow.cs:464:50:464:52 | value | LocalDataFlow.cs:464:64:464:68 | access to parameter value |

0 commit comments

Comments
 (0)