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
This commit is contained in:
Vadim Zeitlin
2009-11-18 03:45:32 +00:00
parent 76d88590ff
commit 0f506ded1a

View File

@@ -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 )
{