diff --git a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt index d220cdbe3..170949bbf 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt @@ -181,8 +181,10 @@ abstract class MagiskInstallImpl protected constructor( return TarEntry(TarHeader.createHeader(name, size, 0, false, 420 /* 0644 */)) } - private class LZ4InputStream(s: InputStream) : LZ4FrameInputStream(s) { - // Workaround bug in LZ4FrameInputStream + private class NoAvailableStream(s: InputStream) : FilterInputStream(s) { + // Make sure available is never called on the actual stream and always return 0 + // 1. Workaround bug in LZ4FrameInputStream + // 2. Reduce max buffer size to prevent OOM override fun available() = 0 } @@ -194,7 +196,8 @@ abstract class MagiskInstallImpl protected constructor( lateinit var entry: TarEntry fun decompressedStream(): InputStream { - return if (entry.name.endsWith(".lz4")) LZ4InputStream(tarIn) else tarIn + val stream = if (entry.name.endsWith(".lz4")) LZ4FrameInputStream(tarIn) else tarIn + return NoAvailableStream(stream) } while (tarIn.nextEntry?.let { entry = it } != null) {