From 78a26fec13eb955bcfcc1c0a896ff2ad448d3c72 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 28 Apr 2019 00:07:28 +0200 Subject: [PATCH] cgo: be able to deal with nil files I'm not sure where they come from but they lead to a crash, so turn them into token.NoPos. --- loader/libclang.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader/libclang.go b/loader/libclang.go index 4292ed884..1d6a9ee8c 100644 --- a/loader/libclang.go +++ b/loader/libclang.go @@ -244,7 +244,7 @@ func (info *fileInfo) getCursorPosition(cursor C.GoCXCursor) token.Pos { var column C.unsigned var offset C.unsigned C.clang_getExpansionLocation(location, &file, &line, &column, &offset) - if line == 0 { + if line == 0 || file == nil { // Invalid token. return token.NoPos }