Fix StackOverflowError

Now field from base class java.io.ByteArrayOutputStream shadows the property with custom getter from derived class com.topjohnwu.magisk.core.utils.AXML.RawByteStream. This behavior will be changed soon in favor of the property. Please use explicit cast to java.io.ByteArrayOutputStream if you wish to preserve current behavior. See https://youtrack.jetbrains.com/issue/KT-55017 for details
This commit is contained in:
vvb2060 2024-07-01 17:17:27 +08:00 committed by John Wu
parent 47e918bc92
commit 9a33a4dfe2

View File

@ -85,7 +85,7 @@ class AXML(b: ByteArray) {
baos.align() baos.align()
val sizeDiff = baos.size() - start - size val sizeDiff = baos.size() - start - size
val newBuffer = ByteBuffer.wrap(baos.buf).order(LITTLE_ENDIAN) val newBuffer = ByteBuffer.wrap(baos.buffer).order(LITTLE_ENDIAN)
// Patch XML size // Patch XML size
newBuffer.putInt(CHUNK_SIZE_OFF, buffer.getInt(CHUNK_SIZE_OFF) + sizeDiff) newBuffer.putInt(CHUNK_SIZE_OFF, buffer.getInt(CHUNK_SIZE_OFF) + sizeDiff)
@ -111,7 +111,7 @@ class AXML(b: ByteArray) {
} }
private class RawByteStream : ByteArrayOutputStream() { private class RawByteStream : ByteArrayOutputStream() {
val buf: ByteArray get() = buf val buffer: ByteArray get() = buf
fun align(alignment: Int = 4) { fun align(alignment: Int = 4) {
val newCount = (count + alignment - 1) / alignment * alignment val newCount = (count + alignment - 1) / alignment * alignment