LibLine: Avoid OOB access when one of the suggestions is the prefix

This commit is contained in:
AnotherTest 2020-04-22 00:31:31 +04:30 committed by Andreas Kling
parent ef69f900c7
commit 730ca98698
Notes: sideshowbarker 2024-07-19 07:24:29 +09:00

View file

@ -385,7 +385,7 @@ String Editor::get_line(const String& prompt)
last_valid_suggestion_char = m_suggestions[0].text[common_suggestion_prefix];
for (const auto& suggestion : m_suggestions) {
if (suggestion.text.length() < common_suggestion_prefix || suggestion.text[common_suggestion_prefix] != last_valid_suggestion_char) {
if (suggestion.text.length() <= common_suggestion_prefix || suggestion.text[common_suggestion_prefix] != last_valid_suggestion_char) {
goto no_more_commons;
}
}