fix segfault when a read_file block lacks a path field (#490)

fixes #489
This commit is contained in:
Michael Stapelberg 2022-06-12 18:34:28 +02:00 committed by GitHub
parent cb516c2df3
commit c1e9069aa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -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);