Skip to content

Commit

Permalink
Fix a segfault caused by wrong textdomain lines in translation files (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Desour committed Aug 12, 2021
1 parent eefa39e commit 0709946
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/translation.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 0709946

Please sign in to comment.