ClangD: Fix possible access violation

Change-Id: I6b54dcdb42f9f9e2c3a9fd686146d253dcdfa40c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Stenger
2021-08-03 12:49:50 +02:00
parent d6acd21fc0
commit f0bc9036f8

View File

@@ -2246,7 +2246,7 @@ static void cleanupDisabledCode(TextEditor::HighlightingResults &results, QTextD
continue;
}
if (wasInDisabled && (it == results.end()
if (wasInDisabled && (it + 1 == results.end()
|| (it + 1)->textStyles.mainStyle != TextEditor::C_DISABLED_CODE)) {
// The #else or #endif that ends disabled code should not be disabled.
it = results.erase(it);