From 8ddce2faaff8405fc1435749631d1926767f9826 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sun, 12 Sep 2021 15:02:04 +0100 Subject: [PATCH] LibWeb: Don't assert if reconsuming on an empty TokenStream This fixes #9978. When a TokenStream is empty, reading its `current_token()` still returns a token (for EOF) so it makes sense to allow users to `reconsume_current_input_token()` that token, so they do not have to handle that themselves. Instead of VERIFY()ing, we can just no-op when reconsuming token 0. --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index dfa0f4d914..11d59cbb44 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -105,8 +105,8 @@ T const& TokenStream::current_token() template void TokenStream::reconsume_current_input_token() { - VERIFY(m_iterator_offset >= 0); - --m_iterator_offset; + if (m_iterator_offset >= 0) + --m_iterator_offset; } template