chromium-89-EnumTable-crash.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. diff --git a/components/cast_channel/enum_table.h b/components/cast_channel/enum_table.h
  2. index e3130c7..2ad16ea 100644
  3. --- a/components/cast_channel/enum_table.h
  4. +++ b/components/cast_channel/enum_table.h
  5. @@ -212,7 +212,7 @@ class
  6. template <typename E>
  7. friend class EnumTable;
  8. - DISALLOW_COPY_AND_ASSIGN(GenericEnumTableEntry);
  9. + DISALLOW_ASSIGN(GenericEnumTableEntry);
  10. };
  11. // Yes, these constructors really needs to be inlined. Even though they look
  12. @@ -250,8 +250,7 @@ class EnumTable {
  13. // Constructor for regular entries.
  14. constexpr Entry(E value, base::StringPiece str)
  15. : GenericEnumTableEntry(static_cast<int32_t>(value), str) {}
  16. -
  17. - DISALLOW_COPY_AND_ASSIGN(Entry);
  18. + DISALLOW_ASSIGN(Entry);
  19. };
  20. static_assert(sizeof(E) <= sizeof(int32_t),
  21. @@ -306,15 +305,14 @@ class EnumTable {
  22. if (is_sorted_) {
  23. const std::size_t index = static_cast<std::size_t>(value);
  24. if (ANALYZER_ASSUME_TRUE(index < data_.size())) {
  25. - const auto& entry = data_.begin()[index];
  26. + const auto& entry = data_[index];
  27. if (ANALYZER_ASSUME_TRUE(entry.has_str()))
  28. return entry.str();
  29. }
  30. return base::nullopt;
  31. }
  32. return GenericEnumTableEntry::FindByValue(
  33. - reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
  34. - data_.size(), static_cast<int32_t>(value));
  35. + &data_[0], data_.size(), static_cast<int32_t>(value));
  36. }
  37. // This overload of GetString is designed for cases where the argument is a
  38. @@ -342,8 +340,7 @@ class EnumTable {
  39. // enum value directly.
  40. base::Optional<E> GetEnum(base::StringPiece str) const {
  41. auto* entry = GenericEnumTableEntry::FindByString(
  42. - reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
  43. - data_.size(), str);
  44. + &data_[0], data_.size(), str);
  45. return entry ? static_cast<E>(entry->value) : base::Optional<E>();
  46. }
  47. @@ -358,7 +355,7 @@ class EnumTable {
  48. // Align the data on a cache line boundary.
  49. alignas(64)
  50. #endif
  51. - std::initializer_list<Entry> data_;
  52. + const std::vector<Entry> data_;
  53. bool is_sorted_;
  54. constexpr EnumTable(std::initializer_list<Entry> data, bool is_sorted)
  55. @@ -370,8 +367,8 @@ class EnumTable {
  56. for (std::size_t i = 0; i < data.size(); i++) {
  57. for (std::size_t j = i + 1; j < data.size(); j++) {
  58. - const Entry& ei = data.begin()[i];
  59. - const Entry& ej = data.begin()[j];
  60. + const Entry& ei = data[i];
  61. + const Entry& ej = data[j];
  62. DCHECK(ei.value != ej.value)
  63. << "Found duplicate enum values at indices " << i << " and " << j;
  64. DCHECK(!(ei.has_str() && ej.has_str() && ei.str() == ej.str()))