Fix segfault in world map export

Attempting to export to write-protected file/directory results in NULL
file reference and leads to segfault when writing/closing it.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Sergey Starosek 2014-07-15 16:45:21 +04:00 committed by Dirk Hohndel
parent d652268655
commit eaacac3217

View file

@ -102,10 +102,11 @@ void export_worldmap_HTML(const char *file_name, const bool selected_only)
export(&buf, selected_only);
f = subsurface_fopen(file_name, "w+");
if (!f)
if (!f) {
report_error(translate("gettextFromC", "Can't open file %s"), file_name);
flush_buffer(&buf, f); /*check for writing errors? */
} else {
flush_buffer(&buf, f); /*check for writing errors? */
fclose(f);
}
free_buffer(&buf);
fclose(f);
}