]> git.saurik.com Git - wxWidgets.git/commitdiff
avoid an assert in wxString::GetWriteBuf()
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Mar 2002 19:15:13 +0000 (19:15 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Mar 2002 19:15:13 +0000 (19:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14727 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/regconf.cpp

index c63a563d6aa3736f1c5f3911379ec25ad2479ae3..6494b321f779b14520f468e33e27b12898f15222 100644 (file)
@@ -350,21 +350,24 @@ void wxRegConfig::SetPath(const wxString& strPath)
 
     // registry APIs want backslashes instead of slashes
     wxString strRegPath;
 
     // registry APIs want backslashes instead of slashes
     wxString strRegPath;
-    size_t len = m_strPath.length();
+    if ( !m_strPath.empty() )
+    {
+        size_t len = m_strPath.length();
 
 
-    const wxChar *src = m_strPath.c_str();
-    wxChar *dst = strRegPath.GetWriteBuf(len);
+        const wxChar *src = m_strPath.c_str();
+        wxChar *dst = strRegPath.GetWriteBuf(len);
 
 
-    const wxChar *end = src + len;
-    for ( ; src < end; src++, dst++ )
-    {
-        if ( *src == wxCONFIG_PATH_SEPARATOR )
-            *dst = _T('\\');
-        else
-            *dst = *src;
-    }
+        const wxChar *end = src + len;
+        for ( ; src < end; src++, dst++ )
+        {
+            if ( *src == wxCONFIG_PATH_SEPARATOR )
+                *dst = _T('\\');
+            else
+                *dst = *src;
+        }
 
 
-    strRegPath.UngetWriteBuf(len);
+        strRegPath.UngetWriteBuf(len);
+    }
 
     // this is not needed any longer as we don't create keys unnecessarily any
     // more (now it is done on demand, i.e. only when they're going to contain
 
     // this is not needed any longer as we don't create keys unnecessarily any
     // more (now it is done on demand, i.e. only when they're going to contain