Skip to content

Commit

Permalink
Fix ArrayIndexOutOfBoundsException in Encoding.decode
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaRGB committed Aug 14, 2022
1 parent 25f9968 commit 19e6487
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion main/java/BitsNPicas/src/com/kreative/mapedit/Mapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ private void decode(CharsetDecoder decoder, byte[] in, int pos, char[] out) {
if (s.contains("\uFFFF")) continue;
CodePointSequence cps = new CodePointSequence(s);
root.setSequence(cps, in, 0, pos + 1);
} else {
} else if (pos + 1 < in.length) {
decode(decoder, in, pos + 1, out);
} else {
System.err.println("Failed to decode encoding " + name + "; it should be added to the list of broken charsets.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ private void decode(CharsetDecoder decoder, byte[] in, int pos, char[] out) {
String s = new String(out, 0, outb.position());
if (s.contains("\uFFFF")) continue;
setSequence(s, in, 0, pos + 1);
} else {
} else if (pos + 1 < in.length) {
decode(decoder, in, pos + 1, out);
} else {
System.err.println("Failed to decode encoding " + name + "; it should be added to the list of broken charsets.");
}
}
}
Expand Down

0 comments on commit 19e6487

Please sign in to comment.