summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sergey Starosek <sergey.starosek@gmail.com>2014-07-15 16:45:21 +0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-15 05:48:07 -0700
commiteaacac321743434ce8610b4b61f56a3fe4a63567 (patch)
tree26f1ee8005cdad36e0fe95e0102c6ddc073c7bba
parentd65226865564f5589b0dbdcb5e8d2c83720a4727 (diff)
downloadsubsurface-eaacac321743434ce8610b4b61f56a3fe4a63567.tar.gz
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>
-rw-r--r--worldmap-save.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/worldmap-save.c b/worldmap-save.c
index dfce3627a..0992b8eb5 100644
--- a/worldmap-save.c
+++ b/worldmap-save.c
@@ -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);
}