Codechange: Make sort list function lists safer. (#12574)
GUIList has a pointer only to the start of each sort/filter func list, which has the potential for UB as it is unable to validate that the selected sort or filter type is in range. Use a std::span instead and check if the selected type is in range before using it.
This commit is contained in:
@@ -62,8 +62,8 @@ protected:
|
||||
|
||||
StoryPageElementID active_button_id; ///< Which button element the player is currently using
|
||||
|
||||
static GUIStoryPageList::SortFunction * const page_sorter_funcs[];
|
||||
static GUIStoryPageElementList::SortFunction * const page_element_sorter_funcs[];
|
||||
static const std::initializer_list<GUIStoryPageList::SortFunction * const> page_sorter_funcs;
|
||||
static const std::initializer_list<GUIStoryPageElementList::SortFunction * const> page_element_sorter_funcs;
|
||||
|
||||
/** (Re)Build story page list. */
|
||||
void BuildStoryPageList()
|
||||
@@ -939,11 +939,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
GUIStoryPageList::SortFunction * const StoryBookWindow::page_sorter_funcs[] = {
|
||||
const std::initializer_list<GUIStoryPageList::SortFunction * const> StoryBookWindow::page_sorter_funcs = {
|
||||
&PageOrderSorter,
|
||||
};
|
||||
|
||||
GUIStoryPageElementList::SortFunction * const StoryBookWindow::page_element_sorter_funcs[] = {
|
||||
const std::initializer_list<GUIStoryPageElementList::SortFunction * const> StoryBookWindow::page_element_sorter_funcs = {
|
||||
&PageElementOrderSorter,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user