mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-25 08:22:17 +00:00
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:
+2
-2
@@ -245,7 +245,7 @@ protected:
|
||||
|
||||
/* Constants for sorting stations */
|
||||
static const StringID sorter_names[];
|
||||
static GUIStationList::SortFunction * const sorter_funcs[];
|
||||
static const std::initializer_list<GUIStationList::SortFunction * const> sorter_funcs;
|
||||
|
||||
FilterState filter;
|
||||
GUIStationList stations{filter.cargoes};
|
||||
@@ -720,7 +720,7 @@ public:
|
||||
};
|
||||
|
||||
/* Available station sorting functions */
|
||||
GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = {
|
||||
const std::initializer_list<GUIStationList::SortFunction * const> CompanyStationsWindow::sorter_funcs = {
|
||||
&StationNameSorter,
|
||||
&StationTypeSorter,
|
||||
&StationWaitingTotalSorter,
|
||||
|
||||
Reference in New Issue
Block a user