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
}
// 1) Determine if the path is relative or absolute.
+
+ if ( path.empty() )
+ {
+ // we had only the volume
+ return;
+ }
+
wxChar leadingChar = path[0u];
switch (format)
{
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 )
{