Skip to content

Commit 507cf11

Browse files
committed
Swift: Add a test case for return values from closures.
1 parent 8875487 commit 507cf11

File tree

1 file changed

+16
-0
lines changed
  • swift/ql/test/library-tests/dataflow/taint/libraries

1 file changed

+16
-0
lines changed

swift/ql/test/library-tests/dataflow/taint/libraries/url.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,19 @@ func taintUrlAsync() async throws {
496496
sink(string: line) // $ MISSING: tainted=490
497497
}
498498
}
499+
500+
func closureReturnValue() {
501+
let url = URL(string: "http://example.com/")!
502+
503+
let r1 = url.withUnsafeFileSystemRepresentation({
504+
ptr in
505+
return "abc"
506+
})
507+
sink(string: r1)
508+
509+
let r2 = url.withUnsafeFileSystemRepresentation({
510+
ptr in
511+
return source() as! String
512+
})
513+
sink(string: r2) // $ tainted=511
514+
}

0 commit comments

Comments
 (0)