mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:52:45 +00:00 
			
		
		
		
	AK: VERIFY() the index is in bounds in StringView::operator[]
That this did not already happen took me by surprise, as for most other similar containers/types in AK (e.g. Span) the index will be checked. This check not happening could easily let off-by-one indexing errors slip through the cracks.
This commit is contained in:
		
							parent
							
								
									5f34c8ab03
								
							
						
					
					
						commit
						13406b83b1
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		|  | @ -62,7 +62,12 @@ public: | |||
| 
 | ||||
|     [[nodiscard]] ReadonlyBytes bytes() const { return { m_characters, m_length }; } | ||||
| 
 | ||||
|     constexpr char const& operator[](size_t index) const { return m_characters[index]; } | ||||
|     constexpr char const& operator[](size_t index) const | ||||
|     { | ||||
|         if (!is_constant_evaluated()) | ||||
|             VERIFY(index < m_length); | ||||
|         return m_characters[index]; | ||||
|     } | ||||
| 
 | ||||
|     using ConstIterator = SimpleIterator<const StringView, char const>; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 MacDue
						MacDue