[Scummvm-git-logs] scummvm master -> 6a3e97d86391202ea01fbdec59219ed006976899

lephilousophe noreply at scummvm.org
Fri Jun 10 05:52:40 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6a3e97d863 GUI: Fix dangling pointer when _headerEntryList was reallocated


Commit: 6a3e97d86391202ea01fbdec59219ed006976899
    https://github.com/scummvm/scummvm/commit/6a3e97d86391202ea01fbdec59219ed006976899
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-06-10T07:52:46+02:00

Commit Message:
GUI: Fix dangling pointer when _headerEntryList was reallocated

As we know the size of the array in advance we can preallocate it.

Changed paths:
    gui/widgets/grid.cpp


diff --git a/gui/widgets/grid.cpp b/gui/widgets/grid.cpp
index 38352ebe006..9f3462087c4 100644
--- a/gui/widgets/grid.cpp
+++ b/gui/widgets/grid.cpp
@@ -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;




More information about the Scummvm-git-logs mailing list