Fixed IndexOutOfBoundsException (#4515)

This commit is contained in:
Maximilian Gama 2019-07-18 06:45:30 +03:00 committed by Ian Luo
parent 0f85bbd66e
commit 8a50b2f783
2 changed files with 12 additions and 0 deletions

View File

@ -730,8 +730,12 @@ public class Bytes {
char pc = code[64];
if (str.charAt(off + len - 2) == pc) {
size -= 2;
--num;
rem = 2;
} else if (str.charAt(off + len - 1) == pc) {
size--;
--num;
rem = 3;
}
} else {
if (rem == 2) {

View File

@ -90,6 +90,14 @@ public class BytesTest {
assertThat(bytes2, is(out2));
}
@Test
public void testBase642bCharArrCall() {
byte[] stringCall = Bytes.base642bytes("ZHViYm8=", C64);
byte[] charArrCall = Bytes.base642bytes("ZHViYm8=", C64.toCharArray());
assertThat(stringCall, is(charArrCall));
}
@Test
public void testHex() {
String str = Bytes.bytes2hex(b1);