Always close outputStream in processFile

Fix #8735
This commit is contained in:
topjohnwu 2025-03-19 17:57:31 -07:00
parent aa35aac5d5
commit f56fd4e215

View File

@ -17,7 +17,6 @@ import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.di.ServiceLocator
import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.core.isRunningAsStub
import com.topjohnwu.magisk.core.ktx.copyAll import com.topjohnwu.magisk.core.ktx.copyAll
import com.topjohnwu.magisk.core.ktx.copyAndClose
import com.topjohnwu.magisk.core.ktx.writeTo import com.topjohnwu.magisk.core.ktx.writeTo
import com.topjohnwu.magisk.core.utils.DummyList import com.topjohnwu.magisk.core.utils.DummyList
import com.topjohnwu.magisk.core.utils.MediaStoreUtils import com.topjohnwu.magisk.core.utils.MediaStoreUtils
@ -500,7 +499,7 @@ abstract class MagiskInstallImpl protected constructor(
bootItem.file = newBoot bootItem.file = newBoot
bootItem.copyTo(outStream as TarArchiveOutputStream) bootItem.copyTo(outStream as TarArchiveOutputStream)
} else { } else {
newBoot.newInputStream().copyAndClose(outStream) newBoot.newInputStream().use { it.copyAll(outStream) }
} }
newBoot.delete() newBoot.delete()
@ -514,6 +513,8 @@ abstract class MagiskInstallImpl protected constructor(
outFile.delete() outFile.delete()
Timber.e(e) Timber.e(e)
return false return false
} finally {
outStream.close()
} }
// Fix up binaries // Fix up binaries