fix: Text highlighter crash (#2595)

The assumption that the number of lines of colors will be equal to the
number of lines in the input signal is incorrect. As issue #2594 shows,
erroneous input can cause the lexer to end processing the input file
prematurely thus being unable to create tokens past the line where the
error occurred which in turn implies that no colors can be found beyond
those lines.

To fix the crash (the underlying problem is user caused and can't be
fixed) is to use the size of the vectors containing the first token
index of each line since that size must be equal to the number of lines
stored in token sequence.

Fixes #2594
This commit is contained in:
paxcut
2026-01-02 08:04:35 -07:00
committed by GitHub
parent ed583d8bd1
commit 5756105347

View File

@@ -1831,7 +1831,7 @@ namespace hex::plugin::builtin {
auto topLine = 0;
while (m_firstTokenIdOfLine.at(topLine) == -1)
topLine++;
auto bottomLine = m_lines.size();
auto bottomLine = previousLine(m_firstTokenIdOfLine.size());
for (u32 line = topLine; line < bottomLine; line = nextLine(line)) {
if (m_lines[line].empty())
continue;