Changeset 281019 in webkit
- Timestamp:
- Aug 13, 2021, 8:38:40 AM (5 years ago)
- Location:
- branches/safari-612.1.28-branch/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
-
branches/safari-612.1.28-branch/Source/WebCore/ChangeLog
r280958 r281019 1 2021-08-13 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r281008. rdar://problem/81901037 4 5 Fix bounds checks for WhitespaceCache string lengths 6 https://bugs.webkit.org/show_bug.cgi?id=229066 7 <rdar://81850871> 8 9 Reviewed by Simon Fraser. 10 11 When the whitespace string length is maximumWhitespaceStringLength, 12 we read from and write to one element past the end of m_codes and 13 m_indexes. Since we don't need to store codes and indexes for zero 14 length strings, subtract one from the index we use. 15 16 * html/parser/HTMLConstructionSite.cpp: 17 (WebCore::WhitespaceCache::lookup): 18 * html/parser/HTMLConstructionSite.h: 19 20 21 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281008 268f45cc-cd09-0410-ab3c-d52691b4dbfc 22 23 2021-08-12 Cameron McCormack <heycam@apple.com> 24 25 Fix bounds checks for WhitespaceCache string lengths 26 https://bugs.webkit.org/show_bug.cgi?id=229066 27 <rdar://81850871> 28 29 Reviewed by Simon Fraser. 30 31 When the whitespace string length is maximumWhitespaceStringLength, 32 we read from and write to one element past the end of m_codes and 33 m_indexes. Since we don't need to store codes and indexes for zero 34 length strings, subtract one from the index we use. 35 36 * html/parser/HTMLConstructionSite.cpp: 37 (WebCore::WhitespaceCache::lookup): 38 * html/parser/HTMLConstructionSite.h: 39 1 40 2021-08-12 Youenn Fablet <youenn@apple.com> 2 41 -
branches/safari-612.1.28-branch/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r280773 r281019 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; -
branches/safari-612.1.28-branch/Source/WebCore/html/parser/HTMLConstructionSite.h
r280772 r281019 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.