@@ -127,18 +127,19 @@ class UnhandledFileCloseDataFlowConfiguration extends DataFlow::Configuration {
127127/**
128128 * Holds if a `node` is preceded by a call to `os.File.Sync`.
129129 */
130- predicate precededBySync ( DataFlow:: Node node , DataFlow:: CallNode call ) {
130+ predicate precededBySync ( DataFlow:: Node closeReceiver , DataFlow:: CallNode closeCall ) {
131131 // using the control flow graph, try to find a call to a handled call to `os.File.Sync`
132132 // 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 |
136134 // match the instruction corresponding to an `os.File.Sync` call with the predecessor
137- syncCall .asInstruction ( ) = instr and
135+ syncCall .asInstruction ( ) = syncInstr and
138136 // check that the call to `os.File.Sync` is handled
139137 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
140141 // 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 )
142143 )
143144}
144145
0 commit comments