File chromium-93-EnumTable-crash.patch of Package chromium-ffmpeg-extra (Revision 4407c879c2f3d7778ebd138b74f5810a)

Currently displaying revision 4407c879c2f3d7778ebd138b74f5810a , Show latest

80
 
1
diff --git a/components/cast_channel/enum_table.h b/components/cast_channel/enum_table.h
2
index a63ae86..83ada65 100644
3
--- a/components/cast_channel/enum_table.h
4
+++ b/components/cast_channel/enum_table.h
5
@@ -8,6 +8,7 @@
6
 #include <cstdint>
7
 #include <cstring>
8
 #include <ostream>
9
+#include <vector>
10
 
11
 #include "base/check_op.h"
12
 #include "base/macros.h"
13
@@ -213,7 +214,7 @@ class
14
 
15
   template <typename E>
16
   friend class EnumTable;
17
-  DISALLOW_COPY_AND_ASSIGN(GenericEnumTableEntry);
18
+  DISALLOW_ASSIGN(GenericEnumTableEntry);
19
 };
20
 
21
 // Yes, these constructors really needs to be inlined.  Even though they look
22
@@ -251,8 +252,7 @@ class EnumTable {
23
     // Constructor for regular entries.
24
     constexpr Entry(E value, base::StringPiece str)
25
         : GenericEnumTableEntry(static_cast<int32_t>(value), str) {}
26
-
27
-    DISALLOW_COPY_AND_ASSIGN(Entry);
28
+    DISALLOW_ASSIGN(Entry);
29
   };
30
 
31
   static_assert(sizeof(E) <= sizeof(int32_t),
32
@@ -307,15 +307,14 @@ class EnumTable {
33
     if (is_sorted_) {
34
       const std::size_t index = static_cast<std::size_t>(value);
35
       if (ANALYZER_ASSUME_TRUE(index < data_.size())) {
36
-        const auto& entry = data_.begin()[index];
37
+        const auto& entry = data_[index];
38
         if (ANALYZER_ASSUME_TRUE(entry.has_str()))
39
           return entry.str();
40
       }
41
       return absl::nullopt;
42
     }
43
     return GenericEnumTableEntry::FindByValue(
44
-        reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
45
-        data_.size(), static_cast<int32_t>(value));
46
+        &data_[0], data_.size(), static_cast<int32_t>(value));
47
   }
48
 
49
   // This overload of GetString is designed for cases where the argument is a
50
@@ -343,8 +342,7 @@ class EnumTable {
51
   // enum value directly.
52
   absl::optional<E> GetEnum(base::StringPiece str) const {
53
     auto* entry = GenericEnumTableEntry::FindByString(
54
-        reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
55
-        data_.size(), str);
56
+        &data_[0], data_.size(), str);
57
     return entry ? static_cast<E>(entry->value) : absl::optional<E>();
58
   }
59
 
60
@@ -359,7 +357,7 @@ class EnumTable {
61
   // Align the data on a cache line boundary.
62
   alignas(64)
63
 #endif
64
-      std::initializer_list<Entry> data_;
65
+      const std::vector<Entry> data_;
66
   bool is_sorted_;
67
 
68
   constexpr EnumTable(std::initializer_list<Entry> data, bool is_sorted)
69
@@ -371,8 +369,8 @@ class EnumTable {
70
 
71
     for (std::size_t i = 0; i < data.size(); i++) {
72
       for (std::size_t j = i + 1; j < data.size(); j++) {
73
-        const Entry& ei = data.begin()[i];
74
-        const Entry& ej = data.begin()[j];
75
+        const Entry& ei = data[i];
76
+        const Entry& ej = data[j];
77
         DCHECK(ei.value != ej.value)
78
             << "Found duplicate enum values at indices " << i << " and " << j;
79
         DCHECK(!(ei.has_str() && ej.has_str() && ei.str() == ej.str()))
80