From 35a33b5c9e3d9d737830a81716a5b28ed7c6b0bf Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Wed, 27 Feb 2019 07:03:42 +0100
Subject: [PATCH] [A/FileIO/GMS] Check before creating pnt fixes leak.

---
 Applications/FileIO/GMSInterface.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/Applications/FileIO/GMSInterface.cpp b/Applications/FileIO/GMSInterface.cpp
index 357ba8a7853..a1dde67f5ea 100644
--- a/Applications/FileIO/GMSInterface.cpp
+++ b/Applications/FileIO/GMSInterface.cpp
@@ -38,18 +38,19 @@ namespace FileIO
 int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes,
                                        const std::string &filename)
 {
+    std::ifstream in(filename.c_str());
+    if (!in.is_open())
+    {
+        ERR("GMSInterface::readBoreholeFromGMS(): Could not open file %s.",
+            filename.c_str());
+        return 0;
+    }
+
     double depth(-9999.0);
     std::string line(""), cName(""), sName("");
     std::list<std::string>::const_iterator it;
     auto* pnt = new GeoLib::Point();
     GeoLib::StationBorehole* newBorehole = nullptr;
-    std::ifstream in( filename.c_str() );
-
-    if (!in.is_open())
-    {
-        ERR("GMSInterface::readBoreholeFromGMS(): Could not open file %s.", filename.c_str());
-        return 0;
-    }
 
     /* skipping first line because it contains field names */
     getline(in, line);
-- 
GitLab