From 80904d1bc786ad2f6f8ab523391edfc82375820d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20S=C5=82odkowicz?= Date: Mon, 17 Dec 2018 04:38:35 +0100 Subject: [PATCH] Fix crash in translations code when no translations are found Fix another regression in wxTranslations in 3.1.2 and check that the vector of acceptable translations is not empty before using its first element. Closes https://github.com/wxWidgets/wxWidgets/pull/1082 Closes #18299. --- src/common/translation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/translation.cpp b/src/common/translation.cpp index 26515b4c9b..08c4bfd7ad 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -1676,9 +1676,9 @@ wxString wxTranslations::GetBestTranslation(const wxString& domain, const wxString& msgIdLanguage) { const wxArrayString allGoodOnes = GetAcceptableTranslations(domain, msgIdLanguage); - - wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]); - return allGoodOnes[0]; + wxString best(allGoodOnes.empty() ? wxString() : allGoodOnes[0]); + wxLogTrace(TRACE_I18N, " => using language '%s'", best); + return best; } wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain,