From 0f506ded1a65f473de9d2810f6ad526741417809 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Wed, 18 Nov 2009 03:45:32 +0000
Subject: [PATCH] Fix handling of invalid paths with multiple columns in
 wxFileName.

SplitVolume() didn't handle colons in the initial position correctly which
surprised SetPath() and led to accessing an out-of-range string element. Fix
SplitVolume() and also add a check to SetPath() itself as it seems like it
could be called with a path containing the volume only.

Closes #11453.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 src/common/filename.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/common/filename.cpp b/src/common/filename.cpp
index 09b03c6251..09b31fd335 100644
--- a/src/common/filename.cpp
+++ b/src/common/filename.cpp
@@ -396,6 +396,13 @@ void wxFileName::SetPath( const wxString& pathOrig, wxPathFormat format )
     }
 
     // 1) Determine if the path is relative or absolute.
+
+    if ( path.empty() )
+    {
+        // we had only the volume
+        return;
+    }
+
     wxChar leadingChar = path[0u];
 
     switch (format)
@@ -2125,8 +2132,11 @@ wxFileName::SplitVolume(const wxString& fullpathWithVolume,
     {
         wxString sepVol = GetVolumeSeparator(format);
 
+        // we have to exclude the case of a colon in the very beginning of the
+        // string as it can't be a volume separator (nor can this be a valid
+        // DOS file name at all but we'll leave dealing with this to our caller)
         size_t posFirstColon = fullpath.find_first_of(sepVol);
-        if ( posFirstColon != wxString::npos )
+        if ( posFirstColon && posFirstColon != wxString::npos )
         {
             if ( pstrVolume )
             {
-- 
2.47.2