Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ public static byte[] toBytesBinary(String in) {
int size = 0;
for (int i = 0; i < in.length(); ++i) {
char ch = in.charAt(i);
if (ch == '\\' && in.length() > i + 1 && in.charAt(i + 1) == 'x') {
if (ch == '\\' && in.length() > i + 3 && in.charAt(i + 1) == 'x') {
// ok, take next 2 hex digits.
char hd1 = in.charAt(i + 2);
char hd2 = in.charAt(i + 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,11 @@ public void testCopy() {
}

@Test
public void testToBytesBinaryTrailingBackslashes() {
public void testToBytesBinaryTruncatedHexDigit() {
try {
Bytes.toBytesBinary("abc\\x00\\x01\\");
Bytes.toBytesBinary("abc\\x00\\x01\\x");
Bytes.toBytesBinary("abc\\x00\\x01\\x0");
} catch (StringIndexOutOfBoundsException ex) {
fail("Illegal string access: " + ex.getMessage());
}
Expand Down