Skip to content

Commit 0709946

Browse files
authoredAug 12, 2021
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.
1 parent eefa39e commit 0709946

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/translation.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ void Translations::loadTranslation(const std::string &data)
6464
line.resize(line.length() - 1);
6565

6666
if (str_starts_with(line, "# textdomain:")) {
67-
textdomain = utf8_to_wide(trim(str_split(line, ':')[1]));
67+
auto parts = str_split(line, ':');
68+
if (parts.size() < 2) {
69+
errorstream << "Invalid textdomain translation line \"" << line
70+
<< "\"" << std::endl;
71+
continue;
72+
}
73+
textdomain = utf8_to_wide(trim(parts[1]));
6874
}
6975
if (line.empty() || line[0] == '#')
7076
continue;

0 commit comments

Comments
 (0)
Please sign in to comment.