Swift: Add a test case for return values from closures.

This commit is contained in:
Geoffrey White
2023-07-05 18:47:58 +01:00
parent 8875487109
commit 507cf116e2

View File

@@ -496,3 +496,19 @@ func taintUrlAsync() async throws {
sink(string: line) // $ MISSING: tainted=490
}
}
func closureReturnValue() {
let url = URL(string: "http://example.com/")!
let r1 = url.withUnsafeFileSystemRepresentation({
ptr in
return "abc"
})
sink(string: r1)
let r2 = url.withUnsafeFileSystemRepresentation({
ptr in
return source() as! String
})
sink(string: r2) // $ tainted=511
}