summaryrefslogtreecommitdiff
path: root/www-client/chromium/files/chromium-123-EnumTable-crash.patch
blob: 3c647892c046a0e21a70e4129791ecf15050cc37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
diff --git a/components/media_router/common/providers/cast/channel/enum_table.h b/components/media_router/common/providers/cast/channel/enum_table.h
index dd58e6cfea..a0fa270bf2 100644
--- a/components/media_router/common/providers/cast/channel/enum_table.h
+++ b/components/media_router/common/providers/cast/channel/enum_table.h
@@ -9,6 +9,7 @@
 #include <cstring>
 #include <optional>
 #include <ostream>
+#include <vector>
 
 #include "base/check_op.h"
 #include "base/notreached.h"
@@ -187,7 +188,6 @@ class
   inline constexpr GenericEnumTableEntry(int32_t value);
   inline constexpr GenericEnumTableEntry(int32_t value, base::StringPiece str);
 
-  GenericEnumTableEntry(const GenericEnumTableEntry&) = delete;
   GenericEnumTableEntry& operator=(const GenericEnumTableEntry&) = delete;
 
  private:
@@ -253,7 +253,6 @@ class EnumTable {
     constexpr Entry(E value, base::StringPiece str)
         : GenericEnumTableEntry(static_cast<int32_t>(value), str) {}
 
-    Entry(const Entry&) = delete;
     Entry& operator=(const Entry&) = delete;
   };
 
@@ -312,15 +311,14 @@ class EnumTable {
     if (is_sorted_) {
       const std::size_t index = static_cast<std::size_t>(value);
       if (ANALYZER_ASSUME_TRUE(index < data_.size())) {
-        const auto& entry = data_.begin()[index];
+        const auto& entry = data_[index];
         if (ANALYZER_ASSUME_TRUE(entry.has_str()))
           return entry.str();
       }
       return std::nullopt;
     }
     return GenericEnumTableEntry::FindByValue(
-        reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
-        data_.size(), static_cast<int32_t>(value));
+        &data_[0], data_.size(), static_cast<int32_t>(value));
   }
 
   // This overload of GetString is designed for cases where the argument is a
@@ -348,8 +346,7 @@ class EnumTable {
   // enum value directly.
   std::optional<E> GetEnum(base::StringPiece str) const {
     auto* entry = GenericEnumTableEntry::FindByString(
-        reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
-        data_.size(), str);
+        &data_[0], data_.size(), str);
     return entry ? static_cast<E>(entry->value) : std::optional<E>();
   }
 
@@ -364,7 +361,7 @@ class EnumTable {
   // Align the data on a cache line boundary.
   alignas(64)
 #endif
-      std::initializer_list<Entry> data_;
+      const std::vector<Entry> data_;
   bool is_sorted_;
 
   constexpr EnumTable(std::initializer_list<Entry> data, bool is_sorted)
@@ -376,8 +373,8 @@ class EnumTable {
 
     for (std::size_t i = 0; i < data.size(); i++) {
       for (std::size_t j = i + 1; j < data.size(); j++) {
-        const Entry& ei = data.begin()[i];
-        const Entry& ej = data.begin()[j];
+        const Entry& ei = data[i];
+        const Entry& ej = data[j];
         DCHECK(ei.value != ej.value)
             << "Found duplicate enum values at indices " << i << " and " << j;
         DCHECK(!(ei.has_str() && ej.has_str() && ei.str() == ej.str()))