From: Vadim Zeitlin Date: Thu, 18 Oct 2012 23:41:08 +0000 (+0000) Subject: Fix bug in wxFileName::Exists("/"). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1e9b3eff21f80eb00f3c5639e0ac9a02f816c9a1 Fix bug in wxFileName::Exists("/"). Don't remove too many trailing slashes, the lone slash of "/" should remain. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 349d00b7e3..d21a7e5017 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -351,7 +351,16 @@ bool DoStatAny(wxStructStat& st, wxString path, const wxFileName* fn) // path and not for the last path element itself. while ( wxEndsWithPathSeparator(path) ) - path.RemoveLast(); + { + const size_t posLast = path.length() - 1; + if ( !posLast ) + { + // Don't turn "/" into empty string. + break; + } + + path.erase(posLast); + } int ret = !fn || fn->ShouldFollowLink() ? wxStat(path, &st) : wxLstat(path, &st);