From a00535f078e0cb89aa70a29b764862162622d6f3 Mon Sep 17 00:00:00 2001 From: Matthew Wesley Date: Wed, 3 Apr 2013 14:58:37 -0400 Subject: [PATCH] Return an empty location instead of segfaulting --- cpp/ycm/ClangCompleter/ClangCompleter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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 ); }