@@ -127,18 +127,19 @@ class UnhandledFileCloseDataFlowConfiguration extends DataFlow::Configuration {
127
127
/**
128
128
* Holds if a `node` is preceded by a call to `os.File.Sync`.
129
129
*/
130
- predicate precededBySync ( DataFlow:: Node node , DataFlow:: CallNode call ) {
130
+ predicate precededBySync ( DataFlow:: Node closeReceiver , DataFlow:: CallNode closeCall ) {
131
131
// using the control flow graph, try to find a call to a handled call to `os.File.Sync`
132
132
// which precedes `closeCall`.
133
- exists ( IR:: Instruction instr , DataFlow:: Node syncReceiver , DataFlow:: CallNode syncCall |
134
- // find a predecessor to `closeCall` in the control flow graph
135
- instr = call .asInstruction ( ) .getAPredecessor * ( ) and
133
+ exists ( IR:: Instruction syncInstr , DataFlow:: Node syncReceiver , DataFlow:: CallNode syncCall |
136
134
// match the instruction corresponding to an `os.File.Sync` call with the predecessor
137
- syncCall .asInstruction ( ) = instr and
135
+ syncCall .asInstruction ( ) = syncInstr and
138
136
// check that the call to `os.File.Sync` is handled
139
137
isHandledSync ( syncReceiver , syncCall ) and
138
+ // find a predecessor to `closeCall` in the control flow graph which dominates the call to
139
+ // `os.File.Close`
140
+ syncInstr .dominatesNode ( closeCall .asInstruction ( ) ) and
140
141
// check that `os.File.Sync` is called on the same object as `os.File.Close`
141
- exists ( DataFlow:: SsaNode ssa | ssa .getAUse ( ) = node and ssa .getAUse ( ) = syncReceiver )
142
+ exists ( DataFlow:: SsaNode ssa | ssa .getAUse ( ) = closeReceiver and ssa .getAUse ( ) = syncReceiver )
142
143
)
143
144
}
144
145
0 commit comments