diff options
| author | Ben Winston | 2024-05-23 21:42:25 -0400 |
|---|---|---|
| committer | Ben Winston | 2024-05-23 21:42:25 -0400 |
| commit | 82126d94b6e08321a44c5d10dd927daa3cd73653 (patch) | |
| tree | 048a064754ff9fd255199e45deaedf22fb381f5f | |
| parent | ae8913bfd92ad4eaaa7bfcf2b2819277568faa59 (diff) | |
bugfix: only open temp file when editing
| -rw-r--r-- | booki.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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); |
