GUI: Fix dangling pointer when _headerEntryList was reallocated

As we know the size of the array in advance we can preallocate it.
This commit is contained in:
Le Philousophe 2022-06-10 07:49:29 +02:00
parent 148cfc1b70
commit 6a3e97d863

View File

@ -470,6 +470,9 @@ void GridWidget::sortGroups() {
// No filter -> display everything with group headers
Common::sort(_groupHeaders.begin(), _groupHeaders.end());
// Avoid reallocation during iteration: that would invalidate our _sortedEntryList items
_headerEntryList.reserve(_groupHeaders.size());
for (uint i = 0; i != _groupHeaders.size(); ++i) {
Common::U32String header = _groupHeaders[i];
Common::U32String displayedHeader;