From aba9c119fa4567dafae69a38e5d6cadc978c9f1c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 25 Jul 2019 21:43:00 +0200 Subject: [PATCH] Don't crash in wx{File,Dir}PickerCtrl::GetTextCtrlValue() If there is no text field, assert and return empty string instead of just crashing. Closes #14078. --- src/common/filepickercmn.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/filepickercmn.cpp b/src/common/filepickercmn.cpp index ad3be2a644..d97de88dcc 100644 --- a/src/common/filepickercmn.cpp +++ b/src/common/filepickercmn.cpp @@ -203,6 +203,8 @@ bool wxFilePickerCtrl::Create(wxWindow *parent, wxString wxFilePickerCtrl::GetTextCtrlValue() const { + wxCHECK_MSG( m_text, wxString(), "Can't be used if no text control" ); + // filter it through wxFileName to remove any spurious path separator return wxFileName(m_text->GetValue()).GetFullPath(); } @@ -241,6 +243,8 @@ bool wxDirPickerCtrl::Create(wxWindow *parent, wxString wxDirPickerCtrl::GetTextCtrlValue() const { + wxCHECK_MSG( m_text, wxString(), "Can't be used if no text control" ); + // filter it through wxFileName to remove any spurious path separator return wxFileName::DirName(m_text->GetValue()).GetPath(); }