Fix message_handler.cc when range is invalid

This commit is contained in:
Fangrui Song 2018-01-12 16:06:39 -08:00
parent 93ba0c532b
commit 45cb0b8cc5

View File

@ -141,7 +141,8 @@ void EmitSemanticHighlighting(QueryDatabase* db,
// shrinking hack, the contained keywords and primitive types will be
// highlighted undesiredly.
auto concise_name = detailed_name.substr(0, detailed_name.find('<'));
if (sym.loc.range.start.line <= working_file->index_lines.size()) {
if (0 < sym.loc.range.start.line &&
sym.loc.range.start.line <= working_file->index_lines.size()) {
const std::string& line =
working_file->index_lines[sym.loc.range.start.line - 1];
sym.loc.range.end.line = sym.loc.range.start.line;