forked from mirror/OpenTTD
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:
@@ -1326,7 +1326,7 @@ protected:
|
||||
|
||||
/* Constants for sorting industries */
|
||||
static const StringID sorter_names[];
|
||||
static GUIIndustryList::SortFunction * const sorter_funcs[];
|
||||
static const std::initializer_list<GUIIndustryList::SortFunction * const> sorter_funcs;
|
||||
|
||||
GUIIndustryList industries{IndustryDirectoryWindow::produced_cargo_filter};
|
||||
Scrollbar *vscroll;
|
||||
@@ -1902,7 +1902,7 @@ public:
|
||||
Listing IndustryDirectoryWindow::last_sorting = {false, 0};
|
||||
|
||||
/* Available station sorting functions. */
|
||||
GUIIndustryList::SortFunction * const IndustryDirectoryWindow::sorter_funcs[] = {
|
||||
const std::initializer_list<GUIIndustryList::SortFunction * const> IndustryDirectoryWindow::sorter_funcs = {
|
||||
&IndustryNameSorter,
|
||||
&IndustryTypeSorter,
|
||||
&IndustryProductionSorter,
|
||||
|
Reference in New Issue
Block a user