From e12bc5c72c7092fb951287d767402048a618a4ad Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Fri, 19 Feb 2016 15:23:39 +0100
Subject: [PATCH] [BL] Test if findLastPathSeparator ret val is usable.

---
 BaseLib/FileTools.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp
index 4bdb248ad23..229e4534b21 100644
--- a/BaseLib/FileTools.cpp
+++ b/BaseLib/FileTools.cpp
@@ -94,6 +94,8 @@ std::string dropFileExtension(std::string const& filename)
 std::string extractBaseName(std::string const& pathname)
 {
 	const std::size_t p = findLastPathSeparator(pathname);
+	if (p == std::string::npos)
+		return pathname;
 	return pathname.substr(p + 1);
 }
 
@@ -131,6 +133,8 @@ std::string copyPathToFileName(const std::string &file_name,
 std::string extractPath(std::string const& pathname)
 {
 	const std::size_t pos = findLastPathSeparator(pathname);
+	if (pos == std::string::npos)
+		return "";
 	return pathname.substr(0, pos + 1);
 }
 const char * pathSeparator =
-- 
GitLab