From 88b2d9ad84b6806ae65b354f85dc3ad5f2cad5ed Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Wed, 8 Jun 2022 19:10:43 +0000 Subject: [PATCH] Fix memory corruption if history is empty. --- src/gui/FileListWidget.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index e4acdc227..2bec83dd3 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -259,16 +259,16 @@ string& FileListWidget::fixPath(string& path) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FileListWidget::addHistory(const FilesystemNode& node) { - //while(_history.size() > _historyIndex) - while(_currentHistory != std::prev(_history.end(), 1)) - _history.pop_back(); + if (_history.size() > 0) { + while(_currentHistory != std::prev(_history.end(), 1)) + _history.pop_back(); - string select = selected().getName(); - _currentHistory->selected = fixPath(select); + string select = selected().getName(); + _currentHistory->selected = fixPath(select); + } _history.emplace_back(node, ".."); _currentHistory = std::prev(_history.end(), 1); - //_historyIndex++; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -