Changeset 281008 in webkit
- Timestamp:
- Aug 12, 2021, 10:45:45 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
html/parser/HTMLConstructionSite.cpp (modified) (2 diffs)
-
html/parser/HTMLConstructionSite.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r281001 r281008 1 2021-08-12 Cameron McCormack <heycam@apple.com> 2 3 Fix bounds checks for WhitespaceCache string lengths 4 https://bugs.webkit.org/show_bug.cgi?id=229066 5 <rdar://81850871> 6 7 Reviewed by Simon Fraser. 8 9 When the whitespace string length is maximumWhitespaceStringLength, 10 we read from and write to one element past the end of m_codes and 11 m_indexes. Since we don't need to store codes and indexes for zero 12 length strings, subtract one from the index we use. 13 14 * html/parser/HTMLConstructionSite.cpp: 15 (WebCore::WhitespaceCache::lookup): 16 * html/parser/HTMLConstructionSite.h: 17 1 18 2021-08-12 David Kilzer <ddkilzer@apple.com> 2 19 -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r280773 r281008 892 892 return AtomString(); 893 893 894 if (m_codes[length] == code) { 895 ASSERT(m_atoms[m_indexes[length]] == string); 896 return m_atoms[m_indexes[length]]; 894 size_t lengthIndex = length - 1; 895 if (m_codes[lengthIndex] == code) { 896 ASSERT(m_atoms[m_indexes[lengthIndex]] == string); 897 return m_atoms[m_indexes[lengthIndex]]; 897 898 } 898 899 … … 900 901 return AtomString(string); 901 902 902 if (m_codes[length ]) {903 if (m_codes[lengthIndex]) { 903 904 AtomString whitespaceAtom(string); 904 m_codes[length ] = code;905 m_atoms[m_indexes[length ]] = whitespaceAtom;905 m_codes[lengthIndex] = code; 906 m_atoms[m_indexes[lengthIndex]] = whitespaceAtom; 906 907 return whitespaceAtom; 907 908 } 908 909 909 910 AtomString whitespaceAtom(string); 910 m_codes[length ] = code;911 m_indexes[length ] = m_atoms.size();911 m_codes[lengthIndex] = code; 912 m_indexes[lengthIndex] = m_atoms.size(); 912 913 m_atoms.append(whitespaceAtom); 913 914 return whitespaceAtom; -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.h
r280772 r281008 239 239 240 240 // Parallel arrays storing a 64 bit code and an index into m_atoms for the 241 // most recently atomized whitespace-only string of a given length. 241 // most recently atomized whitespace-only string of a given length. The 242 // indices into these two arrays are the string length minus 1, so the code 243 // for a whitespace-only string of length 2 is stored at m_codes[1], etc. 242 244 uint64_t m_codes[maximumCachedStringLength] { 0 }; 243 245 uint8_t m_indexes[maximumCachedStringLength] { 0 };
Note:
See TracChangeset
for help on using the changeset viewer.