From 664e5553475265f6ab4d1ccc8ea1aa9efe38675f Mon Sep 17 00:00:00 2001 From: iska Date: Sun, 5 Apr 2015 13:31:59 +0200 Subject: [PATCH] Add index-bounds-check to the list of active formatting elements when inserting at index In some cases the bookmark-index in the adoption-agency-algorithm lies outside the lists bounds, in this case the new elements is to be inserted at the end of the list. --- HTMLKit/HTMLListOfActiveFormattingElements.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HTMLKit/HTMLListOfActiveFormattingElements.m b/HTMLKit/HTMLListOfActiveFormattingElements.m index 3088ce2..9ac1710 100644 --- a/HTMLKit/HTMLListOfActiveFormattingElements.m +++ b/HTMLKit/HTMLListOfActiveFormattingElements.m @@ -75,6 +75,9 @@ - (void)insertElement:(HTMLElement *)element atIndex:(NSUInteger)index { + if (index > _list.count) { + index = _list.count; + } [_list insertObject:element atIndex:index]; }