[Java] lookup by byteArray is giving back wrong entry (#6915)

This commit is contained in:
taroplus
2021-11-15 11:16:45 -08:00
committed by GitHub
parent 6748c373be
commit 927175ea20
2 changed files with 37 additions and 2 deletions

View File

@@ -788,7 +788,12 @@ public class FlexBuffers {
if (io == other.length) {
// in our buffer we have an additional \0 byte
// but this does not exist in regular Java strings, so we return now
return c1 - c2;
int cmp = c1 - c2;
if (cmp != 0 || bb.get(ia) == '\0') {
return cmp;
} else {
return 1;
}
}
}
while (c1 == c2);
@@ -961,7 +966,12 @@ public class FlexBuffers {
if (l2 == other.length) {
// in our buffer we have an additional \0 byte
// but this does not exist in regular Java strings, so we return now
return c1 - c2;
int cmp = c1 - c2;
if (cmp != 0 || bb.get(l1) == '\0') {
return cmp;
} else {
return 1;
}
}
}
while (c1 == c2);