forked from BigfootDev/flatbuffers
[Dart] Actually use resized FlexBuffers buffer (#8935)
When building a FlexBuffer using the Builder and adding data that exceeds the default buffer size (2048 bytes), in _newOffset() a larger buffer is created, but never used. This results in a RangeError. Resolve by actually replacing the too small with the new larger buffer. Add a test that verifies this by adding multiple large strings to a vector.
This commit is contained in:
@@ -5,7 +5,7 @@ import 'types.dart';
|
||||
|
||||
/// The main builder class for creation of a FlexBuffer.
|
||||
class Builder {
|
||||
final ByteData _buffer;
|
||||
ByteData _buffer;
|
||||
List<_StackValue> _stack = [];
|
||||
List<_StackPointer> _stackPointers = [];
|
||||
int _offset = 0;
|
||||
@@ -506,6 +506,7 @@ class Builder {
|
||||
if (prevSize < size) {
|
||||
final newBuf = ByteData(size);
|
||||
newBuf.buffer.asUint8List().setAll(0, _buffer.buffer.asUint8List());
|
||||
_buffer = newBuf;
|
||||
}
|
||||
return newOffset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user