diff options
author | Paulo Pinheiro <paulovictor.pinheiro@gmail.com> | 2019-09-30 23:05:19 +0200 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2019-09-30 14:05:19 -0700 |
commit | d4cae0a62344b37908b1c157fa1cac27270ea0d0 (patch) | |
tree | 72f9444c6fc127dca6e4caec9d49338e1dd46d68 /tests/JavaTest.java | |
parent | f1147f65bbedeee0cf3843bb06313cbe11fc6191 (diff) | |
download | flatbuffers-d4cae0a62344b37908b1c157fa1cac27270ea0d0.tar.gz flatbuffers-d4cae0a62344b37908b1c157fa1cac27270ea0d0.tar.bz2 flatbuffers-d4cae0a62344b37908b1c157fa1cac27270ea0d0.zip |
Fix issue #5542 (#5543)
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
Diffstat (limited to 'tests/JavaTest.java')
-rw-r--r-- | tests/JavaTest.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/JavaTest.java b/tests/JavaTest.java index b24601b8..79fee1ea 100644 --- a/tests/JavaTest.java +++ b/tests/JavaTest.java @@ -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) { |