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.
This commit is contained in:
hesiod 2017-05-30 17:17:51 +03:00 committed by GitHub
parent 20f7314881
commit ba381580af

View File

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