mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-02 02:07:25 +00:00
[Java] Flexbuffers - Negative signed object length (#6651)
* retry with correct email * update JavaTest.java
This commit is contained in:
parent
fbcb3c4236
commit
54c11932fa
2 changed files with 23 additions and 1 deletions
|
|
@ -862,6 +862,27 @@ class JavaTest {
|
|||
TestEq((byte)-1, result[3]);
|
||||
}
|
||||
|
||||
public static void testSingleElementLongBlob() {
|
||||
|
||||
// verifies blobs of up to 2^16 in length
|
||||
for (int i = 2; i <= 1<<16; i = i<<1) {
|
||||
byte[] input = new byte[i-1];
|
||||
for (int index = 0; index < input.length; index++) {
|
||||
input[index] = (byte)(index % 64);
|
||||
}
|
||||
|
||||
FlexBuffersBuilder builder = new FlexBuffersBuilder();
|
||||
builder.putBlob(input);
|
||||
ByteBuffer b = builder.finish();
|
||||
FlexBuffers.Reference r = FlexBuffers.getRoot(b);
|
||||
byte[] result = r.asBlob().getBytes();
|
||||
|
||||
for (int index = 0; index < input.length; index++) {
|
||||
TestEq((byte)(index % 64), result[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void testSingleElementUByte() {
|
||||
FlexBuffersBuilder builder = new FlexBuffersBuilder();
|
||||
builder.putUInt(0xFF);
|
||||
|
|
@ -1084,6 +1105,7 @@ class JavaTest {
|
|||
testSingleElementSmallString();
|
||||
testSingleElementBigString();
|
||||
testSingleElementBlob();
|
||||
testSingleElementLongBlob();
|
||||
testSingleElementVector();
|
||||
testSingleFixedTypeVector();
|
||||
testSingleElementUShort();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue