Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PbList.toFrozenPbList does not freeze the list in-place, allows modifying frozen messages #624

Closed
osa1 opened this issue Apr 22, 2022 · 0 comments · Fixed by #626
Closed
Labels

Comments

@osa1
Copy link
Member

osa1 commented Apr 22, 2022

Discovered this while reading the code.

syntax = "proto3";

message Test {
  repeated int32 ints = 1;
}
import '../test.pb.dart';

void main() {
  Test test1 = Test.create();
  test1.ints.add(123);

  var ints = test1.ints;

  test1.freeze();
  ints.add(456);

  print(test1);
}

Output:

ints: 123
ints: 456

Expected output: it should fail with an exception.

PbList should implement freezing the same way PbMap implements it: set a bool flag in PbList, mark elements of the list as frozen.

@osa1 osa1 added the bug label Apr 22, 2022
@osa1 osa1 changed the title Freezing lists is buggy PbList.toFrozenPbList does not free the list, allows modifying frozen messages Apr 22, 2022
@osa1 osa1 changed the title PbList.toFrozenPbList does not free the list, allows modifying frozen messages PbList.toFrozenPbList does not freeze the list, allows modifying frozen messages Apr 22, 2022
@osa1 osa1 changed the title PbList.toFrozenPbList does not freeze the list, allows modifying frozen messages PbList.toFrozenPbList does not freeze the list elements, allows modifying frozen messages Apr 25, 2022
@osa1 osa1 changed the title PbList.toFrozenPbList does not freeze the list elements, allows modifying frozen messages PbList.toFrozenPbList does not freeze the list in-place, allows modifying frozen messages Apr 28, 2022
@osa1 osa1 closed this as completed in #626 Jun 15, 2022
osa1 added a commit that referenced this issue Jun 15, 2022
- `PbList` is now a single class

- Freezing no longer creates a new list, sets `_isReadOnly` flag of the current
  list

- Freezing `PbList` now freezes elements

`PbList` implementation is now consistent with `PbMap`.

Fixes #624
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant