diff options
author | Jertzukka <Jertzukka@gmail.com> | 2024-06-04 00:10:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 23:10:53 +0200 |
commit | bf9f3ec4f0a987ae1591ab5466f6eee599203c85 (patch) | |
tree | 9ae40f3a2f890603129efecfdb2f7d9cd3f7107a | |
parent | ea7489b93bca1476fd485982ebce8a1b11284ae9 (diff) | |
download | VeraCrypt-bf9f3ec4f0a987ae1591ab5466f6eee599203c85.tar.gz VeraCrypt-bf9f3ec4f0a987ae1591ab5466f6eee599203c85.zip |
Avoid assert by verifying installed languages exist (#1354)
wxDir::GetAllFiles will throw an assert when opening the preferences dialog
if for some reason the user has not installed VeraCrypt properly and is
missing the intended folder. This patch adds a check to ensure the folder
first exists before querying its files.
-rw-r--r-- | src/Main/Forms/PreferencesDialog.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Main/Forms/PreferencesDialog.cpp b/src/Main/Forms/PreferencesDialog.cpp index 90a668e6..c4d5140f 100644 --- a/src/Main/Forms/PreferencesDialog.cpp +++ b/src/Main/Forms/PreferencesDialog.cpp @@ -82,14 +82,16 @@ namespace VeraCrypt LanguageListBox->Append("System default"); LanguageListBox->Append("English"); - size_t langCount; - langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, wxEmptyString, wxDIR_FILES); - for (size_t i = 0; i < langCount; ++i) { - wxFileName filename(langArray[i]); - wxString langId = filename.GetName().AfterLast('.'); - wxString langNative = langEntries[langId]; - if (!langNative.empty()) { - LanguageListBox->Append(langNative); + if (wxDir::Exists(languagesFolder.GetName())) { + size_t langCount; + langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, wxEmptyString, wxDIR_FILES); + for (size_t i = 0; i < langCount; ++i) { + wxFileName filename(langArray[i]); + wxString langId = filename.GetName().AfterLast('.'); + wxString langNative = langEntries[langId]; + if (!langNative.empty()) { + LanguageListBox->Append(langNative); + } } } #endif |