Skip to content

Commit 6761e21

Browse files
committed
Translations: prevent remote crash with invalid translations
1 parent d3f1743 commit 6761e21

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/util/string.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,12 @@ void translate_string(const std::wstring &s, const std::wstring &textdomain,
866866
// Here we have an argument; get its index and add the translated argument to the output.
867867
int arg_index = toutput[j] - L'1';
868868
++j;
869-
result << args[arg_index];
869+
if (0 <= arg_index && (size_t)arg_index < args.size()) {
870+
result << args[arg_index];
871+
} else {
872+
// This is not allowed: show an error message
873+
errorstream << "Ignoring out-of-bounds argument escape sequence in translation" << std::endl;
874+
}
870875
}
871876
res = result.str();
872877
}

0 commit comments

Comments
 (0)