From 36a055f669547bb1e95883a8201a62f4ba58189a Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 14 Jun 2023 00:31:46 +0200 Subject: Linux/macOS: only wipe password/PIM text controls if they are not empty This fixes a crash on macOS with latest wxWidgets 3.2.2.1 where GetLineLength returns -1 --- src/Main/Forms/VolumePasswordPanel.cpp | 6 +++++- src/Main/Forms/VolumePimWizardPage.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Main') diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp index 49c960c2..3b624340 100644 --- a/src/Main/Forms/VolumePasswordPanel.cpp +++ b/src/Main/Forms/VolumePasswordPanel.cpp @@ -459,7 +459,11 @@ namespace VeraCrypt void VolumePasswordPanel::WipeTextCtrl (wxTextCtrl *textCtrl) { - textCtrl->SetValue (wxString (L'X', textCtrl->GetLineLength(0))); + int txtLen = textCtrl->GetLineLength(0); + if (txtLen > 0) + { + textCtrl->SetValue (wxString (L'X', txtLen)); + } GetPassword (textCtrl); } diff --git a/src/Main/Forms/VolumePimWizardPage.cpp b/src/Main/Forms/VolumePimWizardPage.cpp index 7ef8a3a0..c4f7014b 100644 --- a/src/Main/Forms/VolumePimWizardPage.cpp +++ b/src/Main/Forms/VolumePimWizardPage.cpp @@ -110,7 +110,11 @@ namespace VeraCrypt PimSizer->Replace (VolumePimTextCtrl, newTextCtrl); VolumePimTextCtrl->Show (false); - VolumePimTextCtrl->SetValue (wxString (L'X', VolumePimTextCtrl->GetLineLength(0))); + int txtLen = VolumePimTextCtrl->GetLineLength(0); + if (txtLen > 0) + { + VolumePimTextCtrl->SetValue (wxString (L'X', txtLen)); + } GetVolumePim (); Fit(); -- cgit v1.2.3