From 56b30625d0b4e7a66c74ebfe0d768f10603f2375 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 29 Apr 2015 14:06:48 +0200 Subject: [PATCH] Guard against NULL m_fileHistory in wxDocManager::OnMRUFile(). Don't crash if wxDocManager was created with "initialize = false" ctor argument in which case m_fileHistory remains false. Closes #16973. --- src/common/docview.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 8ce279593f..686b5bcbc9 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1147,17 +1147,21 @@ void wxDocManager::OnFileSaveAs(wxCommandEvent& WXUNUSED(event)) void wxDocManager::OnMRUFile(wxCommandEvent& event) { - // Check if the id is in the range assigned to MRU list entries. - const int id = event.GetId(); - if ( id >= wxID_FILE1 && - id < wxID_FILE1 + static_cast(m_fileHistory->GetCount()) ) + if ( m_fileHistory ) { - DoOpenMRUFile(id - wxID_FILE1); - } - else - { - event.Skip(); + // Check if the id is in the range assigned to MRU list entries. + const int id = event.GetId(); + if ( id >= wxID_FILE1 && + id < wxID_FILE1 + static_cast(m_fileHistory->GetCount()) ) + { + DoOpenMRUFile(id - wxID_FILE1); + + // Don't skip the event below. + return; + } } + + event.Skip(); } void wxDocManager::DoOpenMRUFile(unsigned n)