]> git.saurik.com Git - wxWidgets.git/commitdiff
Check string length correctly in wxFileSystem::URLToFileName().
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Feb 2012 17:27:21 +0000 (17:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Feb 2012 17:27:21 +0000 (17:27 +0000)
Check that the string is long enough before accessing its first and second
characters to fix a crash when an empty or one-character string was passed to
wxFileSystem::URLToFileName().

Closes #13920.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/filesys.cpp

index f94b3f5d91fe60b628ad29b8ac778ff7b9fce8e2..9f5a7c9a24c4ccc0e952e85f5a7625eeb64837e0 100644 (file)
@@ -639,7 +639,7 @@ wxFileName wxFileSystem::URLToFileName(const wxString& url)
     // file urls either start with a forward slash (local harddisk),
     // otherwise they have a servername/sharename notation,
     // which only exists on msw and corresponds to a unc
-    if ( path[0u] == wxT('/') && path [1u] != wxT('/'))
+    if ( path.length() > 1 && (path[0u] == wxT('/') && path [1u] != wxT('/')) )
     {
         path = path.Mid(1);
     }