Skip to content

Commit ceb2edd

Browse files
committed
Fix two ArrayIndexOutOfBoundsExceptions in TastyBuffer.
1 parent 10d05f3 commit ceb2edd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/dotty/tools/dotc/core/pickling/TastyBuffer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class TastyBuffer(initialSize: Int) {
4444

4545
/** Write a byte of data. */
4646
def writeByte(b: Int): Unit = {
47-
if (length == bytes.length) bytes = dble(bytes)
47+
if (length >= bytes.length)
48+
bytes = dble(bytes)
4849
bytes(length) = b.toByte
4950
length += 1
5051
}
@@ -116,6 +117,8 @@ class TastyBuffer(initialSize: Int) {
116117
def putNat(at: Addr, x: Int, width: Int): Unit = {
117118
var y = x
118119
var w = width
120+
if(at.index + w >= bytes.length)
121+
bytes = dble(bytes)
119122
var digit = y & 0x7f | 0x80
120123
while (w > 0) {
121124
w -= 1

0 commit comments

Comments
 (0)