mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-02 02:07:25 +00:00
Empty objects that inherit from Sized would try to access internal ByteBuffer when Sized::size was called. So we add a single byte in the empty buffer, so when size() is called it would return 0
This commit is contained in:
parent
f1147f65bb
commit
d4cae0a623
2 changed files with 17 additions and 5 deletions
|
|
@ -887,6 +887,17 @@ class JavaTest {
|
|||
FlexBuffers.getRoot(b.getBuffer()).toString());
|
||||
}
|
||||
|
||||
public static void testFlexBuferEmpty() {
|
||||
FlexBuffers.Blob blob = FlexBuffers.Blob.empty();
|
||||
FlexBuffers.Map ary = FlexBuffers.Map.empty();
|
||||
FlexBuffers.Vector map = FlexBuffers.Vector.empty();
|
||||
FlexBuffers.TypedVector typedAry = FlexBuffers.TypedVector.empty();
|
||||
TestEq(blob.size(), 0);
|
||||
TestEq(map.size(), 0);
|
||||
TestEq(ary.size(), 0);
|
||||
TestEq(typedAry.size(), 0);
|
||||
}
|
||||
|
||||
public static void testHashMapToMap() {
|
||||
int entriesCount = 12;
|
||||
|
||||
|
|
@ -941,6 +952,7 @@ class JavaTest {
|
|||
testSingleElementMap();
|
||||
testFlexBuffersTest();
|
||||
testHashMapToMap();
|
||||
testFlexBuferEmpty();
|
||||
}
|
||||
|
||||
static <T> void TestEq(T a, T b) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue