]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filename.cpp
Fixed some potential buffer overruns
[wxWidgets.git] / src / common / filename.cpp
index 94799d1a964f9aba107c9dc2ea67042523b700bf..18b8b2759e13c80866d5ffa52f0079fafa2b8f00 100644 (file)
@@ -453,6 +453,18 @@ void wxFileName::Assign(const wxString& fullpathOrig,
     Assign(volume, path, name, ext, format);
 }
 
+void wxFileName::Assign(const wxString& pathOrig,
+                        const wxString& name,
+                        const wxString& ext,
+                        wxPathFormat format)
+{
+    wxString volume,
+             path;
+    SplitVolume(pathOrig, &volume, &path, format);
+
+    Assign(volume, path, name, ext, format);
+}
+
 void wxFileName::AssignDir(const wxString& dir, wxPathFormat format)
 {
     Assign(dir, _T(""), format);
@@ -1277,10 +1289,8 @@ wxString wxFileName::GetPathTerminators(wxPathFormat format)
 bool wxFileName::IsPathSeparator(wxChar ch, wxPathFormat format)
 {
     // wxString::Find() doesn't work as expected with NUL - it will always find
-    // it, so it is almost surely a bug if this function is called with NUL arg
-    wxASSERT_MSG( ch != _T('\0'), _T("shouldn't be called with NUL") );
-
-    return GetPathSeparators(format).Find(ch) != wxNOT_FOUND;
+    // it, so test for it separately
+    return ch != _T('\0') && GetPathSeparators(format).Find(ch) != wxNOT_FOUND;
 }
 
 // ----------------------------------------------------------------------------