Ensure strings are null terminated when written from Dart (#4862)

* Update for Dart 2.x constants

* Fix strings, update test, add CHANGELOG for Dart
This commit is contained in:
Dan Field
2018-08-09 12:50:54 -04:00
committed by Wouter van Oortmerssen
parent 38a6623f34
commit fd40cc61a4
6 changed files with 46 additions and 32 deletions

View File

@@ -662,7 +662,7 @@ class Builder {
// TODO(scheglov) optimize for ASCII strings
List<int> bytes = utf8.encode(value);
int length = bytes.length;
_prepare(4, 1, additionalBytes: length);
_prepare(4, 1, additionalBytes: length + 1);
final int result = _tail;
_setUint32AtTail(_buf, _tail, length);
int offset = _buf.lengthInBytes - _tail + 4;