close FileInputStreams to prevent resource leak

This commit is contained in:
davotoula
2025-09-06 16:31:22 +02:00
parent 16b5d44c3d
commit 9be55eda07
2 changed files with 5 additions and 3 deletions

View File

@@ -50,8 +50,10 @@ class CrashReportCache(
suspend fun loadAndDelete(): String? =
withContext(Dispatchers.IO) {
val stack =
inputStreamOrNull()?.let { inStream ->
InputStreamReader(inStream).readText()
inputStreamOrNull()?.use { inStream ->
InputStreamReader(inStream).use { reader ->
reader.readText()
}
}
deleteReport()
stack

View File

@@ -73,7 +73,7 @@ abstract class OpCrypto internal constructor() : OpUnary() {
}
@Throws(IOException::class, NoSuchAlgorithmException::class)
fun hashFd(file: File?): ByteArray = hashFd(FileInputStream(file))
fun hashFd(file: File?): ByteArray = FileInputStream(file).use { inputStream -> hashFd(inputStream) }
@Throws(IOException::class, NoSuchAlgorithmException::class)
fun hashFd(bytes: ByteArray): ByteArray {