mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
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
(cherry picked from commit 5756105347)
This commit is contained in:
@@ -1575,7 +1575,9 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void TextHighlighter::setRequestedIdentifierColors() {
|
||||
auto topLine = 0;
|
||||
auto bottomLine = m_lines.size();
|
||||
while (m_firstTokenIdOfLine.at(topLine) == -1)
|
||||
topLine++;
|
||||
auto bottomLine = previousLine(m_firstTokenIdOfLine.size());
|
||||
for (u32 line = topLine; line < bottomLine; line = nextLine(line)) {
|
||||
if (m_lines[line].empty())
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user