From faa262ba95be60e47a072382749723583e6528c2 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sun, 10 Nov 2024 20:47:56 +0900 Subject: [PATCH] Check if fopen() fails during generating html --- src/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.c b/src/main.c index 9a8f63a..1f8466e 100644 --- a/src/main.c +++ b/src/main.c @@ -450,6 +450,12 @@ int generate_paths_fn(const void *key, // Save the html. FILE *fd = fopen(generated_path, "wb"); + if (!fd) { + fprintf(stderr, + "WARNING Failed to open \"%s\" for writing, skipping!\n", + generated_path); + return 0; + } unsigned long fwrite_ret = fwrite(html_buf, 1, html_buf_size, fd); if (fwrite_ret < html_buf_size) { fclose(fd);