From 7e18e6e37bb2593e9e3e6b6bb2976528d29a5286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sat, 26 Feb 2022 15:11:00 +0100 Subject: [PATCH] AK: Skip over initial empty chunks in DisjointChunks This will be caught by new test cases: when the initial chunk is empty, a dereference before calling operator++ on the iterator will crash as the initial chunk's size is never checked. --- AK/DisjointChunks.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AK/DisjointChunks.h b/AK/DisjointChunks.h index e991ba8c83..8a93f80e63 100644 --- a/AK/DisjointChunks.h +++ b/AK/DisjointChunks.h @@ -24,6 +24,8 @@ struct DisjointIterator { DisjointIterator(ReferenceType chunks) : m_chunks(chunks) { + while (m_chunk_index < m_chunks.size() && m_chunks[m_chunk_index].is_empty()) + ++m_chunk_index; } DisjointIterator(ReferenceType chunks, EndTag)