diff --git a/tagmanager/ctags/read.c b/tagmanager/ctags/read.c index 038410f8..5a1f2ce7 100644 --- a/tagmanager/ctags/read.c +++ b/tagmanager/ctags/read.c @@ -506,9 +506,10 @@ extern int fileGetc (void) extern int fileGetNthPrevC (unsigned int nth, int def) { const unsigned char *base = (unsigned char *) vStringValue (File.line); + const unsigned int offset = File.ungetchIdx + 1 + nth; - if (File.currentLine - File.ungetchIdx - 1 - nth >= base) - return (int) *(File.currentLine - File.ungetchIdx - 1 - nth); + if (File.currentLine != NULL && File.currentLine >= base + offset) + return (int) *(File.currentLine - offset); else return def; }