diff --git a/cpp/ycm/ClangCompleter/ClangCompleter.cpp b/cpp/ycm/ClangCompleter/ClangCompleter.cpp index 9fd5f29a..a7345a86 100644 --- a/cpp/ycm/ClangCompleter/ClangCompleter.cpp +++ b/cpp/ycm/ClangCompleter/ClangCompleter.cpp @@ -272,6 +272,9 @@ Location ClangCompleter::GetDeclarationLocation( filename, unsaved_files, flags ); + if (!unit) { + return Location(); + } return unit->GetDeclarationLocation( line, column, unsaved_files ); } @@ -286,6 +289,9 @@ Location ClangCompleter::GetDefinitionLocation( filename, unsaved_files, flags ); + if (!unit) { + return Location(); + } return unit->GetDefinitionLocation( line, column, unsaved_files ); }