From 82126d94b6e08321a44c5d10dd927daa3cd73653 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Thu, 23 May 2024 21:42:25 -0400 Subject: bugfix: only open temp file when editing --- booki.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/booki.c b/booki.c index a1215ec..7f462eb 100644 --- a/booki.c +++ b/booki.c @@ -480,7 +480,9 @@ char** search(int argc, char* argv[], char* booki_file) { return NULL; } - FILE *output = fopen(EDIT_FILE, "w"); + FILE *output = NULL; + if (search_opts.edit) + output = fopen(EDIT_FILE, "w"); // book loop struct Book books[MAX_BOOKS]; @@ -537,7 +539,8 @@ char** search(int argc, char* argv[], char* booki_file) { } free(data); - fclose(output); + if (output) + fclose(output); if (search_opts.edit) open(EDIT_FILE); -- cgit v1.2.3