Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: lib/src/protobuf/coded_buffer_reader.dart

Issue 885223002: Bugfix for broken protobuf decoding in case of Uint8List views with non-zero offsets (Closed) Base URL: https://github.com/dart-lang/dart-protobuf.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/protobuf/coded_buffer_reader.dart
diff --git a/lib/src/protobuf/coded_buffer_reader.dart b/lib/src/protobuf/coded_buffer_reader.dart
index fa0b99f70266f12738f6dc0224b9a3a12f8ad7fd..a22b8f1ed7e0df8bdd158c4a664bac8c6c0aa191 100644
--- a/lib/src/protobuf/coded_buffer_reader.dart
+++ b/lib/src/protobuf/coded_buffer_reader.dart
@@ -127,7 +127,8 @@ class CodedBufferReader {
List<int> readBytes() {
int length = readInt32();
_checkLimit(length);
- return new Uint8List.view(_buffer.buffer, _bufferPos - length, length);
+ return new Uint8List.view(_buffer.buffer,
+ _buffer.offsetInBytes + _bufferPos - length, length);
}
String readString() => _UTF8.decode(readBytes());
double readFloat() =>
@@ -210,7 +211,7 @@ class CodedBufferReader {
ByteData _readByteData(int sizeInBytes) {
_checkLimit(sizeInBytes);
- return new ByteData.view(
- _buffer.buffer, _bufferPos - sizeInBytes, sizeInBytes);
+ return new ByteData.view(_buffer.buffer,
+ _buffer.offsetInBytes + _bufferPos - sizeInBytes, sizeInBytes);
}
}
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698