)]}'
{
  "commit": "9da84aef9d8126ac3da665f3c163e3cb4af31b6d",
  "tree": "1acbec915712f42580542e0d76d9035867689c44",
  "parents": [
    "6be405f9699bbebc502f199af1427d695b7546b2"
  ],
  "author": {
    "name": "Ömer Sinan Ağacan",
    "email": "omersa@google.com",
    "time": "Tue Mar 29 14:16:43 2022 +0200"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Mar 29 14:16:43 2022 +0200"
  },
  "message": "Fix a potential issue in CodedBufferWriter (#594)\n\nCurrently `CodedBufferWriter`, when serializing a field, manually masks\r\nthe \"repeated\", \"required\", and \"packed\" bits to get the \"base type\" of\r\nthe field.\r\n\r\nHowever it also needs to mask the \"map\" bit as the function to map the\r\n\"base type\" to an array index (`_valueTypeIndex`) only works for values\r\nthat are a power of 2, i.e. there needs to be at most one bit set.\r\n\r\nThis code still works today because of the special case when the map bit\r\nset, after getting the base type incorrectly.\r\n\r\nIn other words, when the map bit is set we compute the wire type\r\nincorrectly, but we don\u0027t use the incorrect value.\r\n\r\nChanged in this PR:\r\n\r\n1. `_valueTypeIndex` now has an assertion checking that the argument is\r\n   really a power of 2.\r\n\r\n2. `valueType` is now computed using `PbFieldType._baseType`, which\r\n   correctly masks the \"map\" bit.\r\n\r\n3. `wireFormat` is moved after the special case that checks for the map\r\n   bit.\r\n\r\nWith (1) tests in protoc_compiler start to fail. Either one of (2) or\r\n(3) fixes the issue, but I think both are improvements.\r\n\r\nJSON serializers correctly use the `PbFieldType._baseType` function to\r\nget the base type so no changes needed.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b1821d898f29aadce451682c5dccb99689ec74e5",
      "old_mode": 33188,
      "old_path": "protobuf/lib/src/protobuf/coded_buffer_writer.dart",
      "new_id": "2c8f37f886a07e216b9daaa8b2830384000f0c36",
      "new_mode": 33188,
      "new_path": "protobuf/lib/src/protobuf/coded_buffer_writer.dart"
    }
  ]
}
