Skip to content

Accessing the array property with an empty array results in a negative array index #43

@IceDynamix

Description

@IceDynamix

func set_element_count(element_count: int, force_update: bool = false) -> void:
element_count = maxi(element_count, 0)
if _element_count == element_count and not force_update:
return
_hseparator.set_visible(element_count > PAGE_SIZE)
_footer.set_visible(_hseparator.is_visible())
_page_count = floori(float(element_count - 1) / PAGE_SIZE)
_page_label.set_text("/ %d" % _page_count)
_current_page = clampi(_current_page, 0, _page_count)
_page_edit.set_text(str(_current_page))
_element_count = element_count
update_elements()

If the element count is 0, it will calculate a page_count of -1 and set a current_page of -1.

Eventually, it will construct a page starting from array index _current_page * PAGE_SIZE, which is negative and results in a runtime exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions