mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Kotlin: Add FP test cases for resource leaks
This commit is contained in:
@@ -0,0 +1 @@
|
||||
| CloseReader.kt:4:20:4:45 | new FileReader(...) | This FileReader is not always closed on method exit. |
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.io.*
|
||||
|
||||
fun test0() {
|
||||
BufferedReader(FileReader("C:\\test.txt")).use { bw ->
|
||||
bw.readLine()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Likely Bugs/Resource Leaks/CloseReader.ql
|
||||
@@ -0,0 +1,8 @@
|
||||
| CloseWriter.kt:4:29:4:54 | new FileWriter(...) | This FileWriter is not always closed on method exit. |
|
||||
| CloseWriter.kt:9:20:9:45 | new FileWriter(...) | This FileWriter is not always closed on method exit. |
|
||||
| CloseWriter.kt:15:14:15:57 | new FileOutputStream(...) | This FileOutputStream is not always closed on method exit. |
|
||||
| CloseWriter.kt:20:5:20:48 | new FileOutputStream(...) | This FileOutputStream is not always closed on method exit. |
|
||||
| CloseWriter.kt:26:33:26:76 | new FileOutputStream(...) | This FileOutputStream is not always closed on method exit. |
|
||||
| CloseWriter.kt:31:24:31:67 | new FileOutputStream(...) | This FileOutputStream is not always closed on method exit. |
|
||||
| CloseWriter.kt:37:33:37:76 | new FileOutputStream(...) | This FileOutputStream is not always closed on method exit. |
|
||||
| CloseWriter.kt:42:24:42:67 | new FileOutputStream(...) | This FileOutputStream is not always closed on method exit. |
|
||||
45
java/ql/test/kotlin/query-tests/CloseWriter/CloseWriter.kt
Normal file
45
java/ql/test/kotlin/query-tests/CloseWriter/CloseWriter.kt
Normal file
@@ -0,0 +1,45 @@
|
||||
import java.io.*
|
||||
|
||||
fun test0() {
|
||||
val bw = BufferedWriter(FileWriter("C:\\test.txt"))
|
||||
bw.write("test")
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
BufferedWriter(FileWriter("C:\\test.txt")).use { bw ->
|
||||
bw.write("test")
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
val bw = FileOutputStream(File.createTempFile("","")).bufferedWriter()
|
||||
bw.write("test")
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
FileOutputStream(File.createTempFile("","")).bufferedWriter().use { bw ->
|
||||
bw.write("test")
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
val bw = OutputStreamWriter(FileOutputStream(File.createTempFile("",""))).buffered()
|
||||
bw.write("test")
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
OutputStreamWriter(FileOutputStream(File.createTempFile("",""))).buffered().use { bw ->
|
||||
bw.write("test")
|
||||
}
|
||||
}
|
||||
|
||||
fun test6() {
|
||||
val bw = OutputStreamWriter(FileOutputStream(File.createTempFile("","")))
|
||||
bw.write("test")
|
||||
}
|
||||
|
||||
fun test7() {
|
||||
OutputStreamWriter(FileOutputStream(File.createTempFile("",""))).use { bw ->
|
||||
bw.write("test")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Likely Bugs/Resource Leaks/CloseWriter.ql
|
||||
Reference in New Issue
Block a user