Repository navigation
Tags: google/protobuf.dart
Tags
Check key and value validity in PbMap (#1076) Currently `PbMap` does not check ranges of values added as keys or values. This allows serializing and deserializing a message with a map and getting a different map back, because `PbMap` allows adding values that are out of range (e.g. an integer larger than 32-bit range as a `sfixed32` value) but when serializing it truncates the value. Update `PbMap` to use the same validation functions as `PbList` when adding elements. Both keys and values are checked. Fixes #1065.
Check key and value validity in PbMap (#1076) Currently `PbMap` does not check ranges of values added as keys or values. This allows serializing and deserializing a message with a map and getting a different map back, because `PbMap` allows adding values that are out of range (e.g. an integer larger than 32-bit range as a `sfixed32` value) but when serializing it truncates the value. Update `PbMap` to use the same validation functions as `PbList` when adding elements. Both keys and values are checked. Fixes #1065.
Don't iterate iterable arguments twice in PbList (#1070) Update `PbList` methods that update the list with an `Iterable` argument to avoid iterating the iterable twice: once for checking the element validity and once again for actually adding the values. Methods updated: - addAll - insertAll - replaceRange - setAll - setRange Exception handling behavior before this PR was undefined (same as the standard library `List`), and it's slightly changed with this PR: - addAll: previously if the iterator throws the list was left unchanged, now the elements until the exception will be added. - Other methods: exception behaviors are now the same as the standard library `List` methods. It's hard to tell whether the previous behavior was the same or different with the standard library `List` methods, as the exception behavior of those are undefined. To avoid allocating new iterators when a check function is not available, we have conditionals in each of these methods and call the standard library `List` methods directly when there isn't a check function. To avoid increasing number of cases needed to be tested, we don't special case iterable types like `PbList` and `List` in these methods. When the check function is available we simply `map` them with the check function. Otherwise call the same method on `wrappedList` directly. Fixes #730.
PreviousNext