forked from BigfootDev/flatbuffers
[FlexBuffers][Java] Fix wrong access to a string using Reference::asString(). (#5532)
The real position of a string is calculated by using the indirect() method, which should be based on parentWidth and not byteWidth, as it was implemented. We are also fixing the flag BUILDER_FLAG_SHARE_STRINGS on FlexBuffersBuilder that was set as '1', same value as BUILDER_FLAG_SHARE_KEYS.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
cbdf82e2fb
commit
0798b7b698
@@ -481,7 +481,7 @@ public class FlexBuffers {
|
||||
*/
|
||||
public String asString() {
|
||||
if (isString()) {
|
||||
int start = indirect(bb, end, byteWidth);
|
||||
int start = indirect(bb, end, parentWidth);
|
||||
int size = readInt(bb, start - byteWidth, byteWidth);
|
||||
return Utf8.getDefault().decodeUtf8(bb, start, size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user