aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2021-08-12 20:06:18 +0200
committerGitHub <noreply@github.com>2021-08-12 20:06:18 +0200
commit0709946c75ae6f2257d368714185bed7bee538ba (patch)
treea41acfe0eb358a752d286ac9a3ad88cf2fea90d5 /src
parenteefa39e47b4ef1f6a51854461efee99777ae20fd (diff)
downloadminetest-0709946c75ae6f2257d368714185bed7bee538ba.tar.gz
minetest-0709946c75ae6f2257d368714185bed7bee538ba.tar.bz2
minetest-0709946c75ae6f2257d368714185bed7bee538ba.zip
Fix a segfault caused by wrong textdomain lines in translation files (#11530)
* The problem were lines like these: "# textdomain:" * str_split does not add an empty last part if there is a delimiter at the end, but this was probably assumed here.
Diffstat (limited to 'src')
-rw-r--r--src/translation.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/translation.cpp b/src/translation.cpp
index 55c958fa2..1e43b0894 100644
--- a/src/translation.cpp
+++ b/src/translation.cpp
@@ -64,7 +64,13 @@ void Translations::loadTranslation(const std::string &data)
line.resize(line.length() - 1);
if (str_starts_with(line, "# textdomain:")) {
- textdomain = utf8_to_wide(trim(str_split(line, ':')[1]));
+ auto parts = str_split(line, ':');
+ if (parts.size() < 2) {
+ errorstream << "Invalid textdomain translation line \"" << line
+ << "\"" << std::endl;
+ continue;
+ }
+ textdomain = utf8_to_wide(trim(parts[1]));
}
if (line.empty() || line[0] == '#')
continue;