From 57090f75ae45c8980583b3eef420228e318d3d90 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 12 Mar 2022 23:48:05 +0200 Subject: [PATCH] LibWeb: Correct invalid index check in HTMLTableElement::insertRow() As well as change the matching error message in deleteRow(), which likely caused this mistake in the first place. --- Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index cbb0045b86..d9a161ad25 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -284,7 +284,7 @@ DOM::ExceptionOr> HTMLTableElement::insert_ro auto rows = this->rows(); auto rows_length = rows->length(); - if (index < -1 || index >= (long)rows_length) { + if (index < -1 || index > (long)rows_length) { return DOM::IndexSizeError::create("Index is negative or greater than the number of rows"); } auto tr = static_ptr_cast(DOM::create_element(document(), TagNames::tr, Namespace::HTML)); @@ -312,7 +312,7 @@ DOM::ExceptionOr HTMLTableElement::delete_row(long index) // 1. If index is less than −1 or greater than or equal to the number of elements in the rows collection, then throw an "IndexSizeError" DOMException. if (index < -1 || index >= (long)rows_length) - return DOM::IndexSizeError::create("Index is negative or greater than the number of rows"); + return DOM::IndexSizeError::create("Index is negative or greater than or equal to the number of rows"); // 2. If index is −1, then remove the last element in the rows collection from its parent, or do nothing if the rows collection is empty. if (index == -1) {