From 7c89d32158d0719927ed9b54a1aad8d4a23a4eca Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.watanabe@ufz.de>
Date: Fri, 17 Oct 2014 10:09:00 +0200
Subject: [PATCH] check output stream in writing TIN

---
 FileIO/TINInterface.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/FileIO/TINInterface.cpp b/FileIO/TINInterface.cpp
index 84df0339161..c543e733184 100644
--- a/FileIO/TINInterface.cpp
+++ b/FileIO/TINInterface.cpp
@@ -121,6 +121,10 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname,
 void TINInterface::writeSurfaceAsTIN(GeoLib::Surface const& surface, std::string const& file_name)
 {
 	std::ofstream os (file_name.c_str());
+	if (!os) {
+		WARN("writeSurfaceAsTIN(): could not open stream to %s.", file_name.c_str());
+		return;
+	}
 	os.precision(std::numeric_limits<double>::digits10);
 	const std::size_t n_tris (surface.getNTriangles());
 	for (std::size_t l(0); l < n_tris; l++) {
-- 
GitLab