From ba381580afd49e8be4baae142b91a4b28fa4f722 Mon Sep 17 00:00:00 2001 From: hesiod Date: Tue, 30 May 2017 17:17:51 +0300 Subject: [PATCH] Fix null pointer dereference write_string_to_file would try to write the error message that it failed to open a file stream to the very same file stream it just tried to open. Fix this by writing to stderr instead. --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 5787ac11..d24c3a5b 100644 --- a/main.cpp +++ b/main.cpp @@ -192,7 +192,7 @@ static bool write_string_to_file(const char *path, const char *string) FILE *file = fopen(path, "w"); if (!file) { - fprintf(file, "Failed to write file: %s\n", path); + fprintf(stderr, "Failed to write file: %s\n", path); return false; }