From c1e9069aa13a4e9b262be01418ff26167df69d8d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 12 Jun 2022 18:34:28 +0200 Subject: [PATCH] fix segfault when a read_file block lacks a path field (#490) fixes #489 --- src/print_file_contents.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/print_file_contents.c b/src/print_file_contents.c index 3e165ff..486d91b 100644 --- a/src/print_file_contents.c +++ b/src/print_file_contents.c @@ -19,6 +19,12 @@ void print_file_contents(file_contents_ctx_t *ctx) { char *outwalk = ctx->buf; char *buf = scalloc(ctx->max_chars * sizeof(char) + 1); + if (ctx->path == NULL) { + OUTPUT_FULL_TEXT("error: path not configured"); + free(buf); + return; + } + char *abs_path = resolve_tilde(ctx->path); int fd = open(abs_path, O_RDONLY); free(abs_path);