aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/translation.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/translation.cpp b/common/translation.cpp
index 5598cbcf8c..d29e7b5c72 100644
--- a/common/translation.cpp
+++ b/common/translation.cpp
@@ -196,8 +196,14 @@ const char *TranslationManager::getLangById(int id) {
case kTranslationBuiltinId:
return "C";
default:
- return po2c_getlang(id - 1);
+ if (id >= 0 && id - 1 < po2c_getnumlangs())
+ return po2c_getlang(id - 1);
}
+
+ // In case an invalid ID was specified, we will output a warning
+ // and return the same value as the auto detection id.
+ warning("Invalid language id %d passed to TranslationManager::getLangById", id);
+ return "";
}
#else // TRANSLATION