From ac31669ec3884cb7254cb4d2e249c600e7172887 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 25 May 2018 19:25:11 +0200 Subject: [PATCH] linter: don't try to access absent stat info, as that gives a crash This fixes https://savannah.gnu.org/bugs/?53981. --- src/text.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/text.c b/src/text.c index d0b2f564..a17b3c6e 100644 --- a/src/text.c +++ b/src/text.c @@ -3267,16 +3267,18 @@ void do_linter(void) struct stat lintfileinfo; if (stat(curlint->filename, &lintfileinfo) != -1 && - openfile->current_stat->st_ino != lintfileinfo.st_ino) { + (openfile->current_stat == NULL || + openfile->current_stat->st_ino != lintfileinfo.st_ino)) { #ifdef ENABLE_MULTIBUFFER const openfilestruct *started_at = openfile; openfile = openfile->next; - while (openfile != started_at && - openfile->current_stat->st_ino != lintfileinfo.st_ino) + while (openfile != started_at && (openfile->current_stat == NULL || + openfile->current_stat->st_ino != lintfileinfo.st_ino)) openfile = openfile->next; - if (openfile->current_stat->st_ino != lintfileinfo.st_ino) { + if (openfile->current_stat == NULL || + openfile->current_stat->st_ino != lintfileinfo.st_ino) { char *msg = charalloc(1024 + strlen(curlint->filename)); int i;