From b59017938b4551ae11e0e4c241f5e1068cf293ec Mon Sep 17 00:00:00 2001 From: Dominic Fischer Date: Sun, 21 Jul 2019 19:11:53 +0100 Subject: [PATCH] Fix potential leak Signed-off-by: Dominic Fischer --- .../im/vector/matrix/android/internal/util/FileSaver.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/FileSaver.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/FileSaver.kt index 9654f5e097..4f695d2c74 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/FileSaver.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/FileSaver.kt @@ -26,11 +26,8 @@ import java.io.InputStream */ @WorkerThread fun writeToFile(inputStream: InputStream, outputFile: File) { - val source = Okio.buffer(Okio.source(inputStream)) - val sink = Okio.buffer(Okio.sink(outputFile)) - - source.use { input -> - sink.use { output -> + Okio.buffer(Okio.source(inputStream)).use { input -> + Okio.buffer(Okio.sink(outputFile)).use { output -> output.writeAll(input) } }