Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revise the overflow in UTF8String
  • Loading branch information
ulysses-you committed Apr 13, 2021
commit d43643e54d06d0d0573ee7075df7f07f9f2b838a
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ public UTF8String rpad(int len, UTF8String pad) {
// the partial string of the padding
UTF8String remain = pad.substring(0, spaces - padChars * count);

byte[] data = new byte[this.numBytes + pad.numBytes * count + remain.numBytes];
int resultSize = Math.toIntExact((long)numBytes + pad.numBytes * count + remain.numBytes);
byte[] data = new byte[resultSize];
copyMemory(this.base, this.offset, data, BYTE_ARRAY_OFFSET, this.numBytes);
int offset = this.numBytes;
int idx = 0;
Expand Down Expand Up @@ -939,7 +940,8 @@ public UTF8String lpad(int len, UTF8String pad) {
// the partial string of the padding
UTF8String remain = pad.substring(0, spaces - padChars * count);

byte[] data = new byte[this.numBytes + pad.numBytes * count + remain.numBytes];
int resultSize = Math.toIntExact((long)numBytes + pad.numBytes * count + remain.numBytes);
byte[] data = new byte[resultSize];

int offset = 0;
int idx = 0;
Expand Down