]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/debughlp.cpp
Allow translated 'Space' in menu accelerators (perhaps more entries should allow...
[wxWidgets.git] / src / msw / debughlp.cpp
index 8075dd672a85b53a4181becbb74cad72fbfe1c6a..0f72ce897c0cfab576c763861c457635c8a97dde 100644 (file)
@@ -399,10 +399,24 @@ wxDbgHelpDLL::DumpUDT(PSYMBOL_INFO pSym, void *pVariable, unsigned level)
     {
         wxString *ps = (wxString *)pVariable;
 
-        // take care to use c_str() here as otherwise we might hit an assert in
-        // wxString code if it is currently locked for writing (i.e. we're
-        // between GetWriteBuf() and UngetWriteBuf() calls)
-        s << _T("(\"") << ps->c_str() << _T(")\"");
+        // we can't just dump wxString directly as it could be corrupted or
+        // invalid and it could also be locked for writing (i.e. if we're
+        // between GetWriteBuf() and UngetWriteBuf() calls) and assert when we
+        // try to access it contents using public methods, so instead use our
+        // knowledge of its internals
+        const wxChar *p = NULL;
+        if ( !::IsBadReadPtr(ps, sizeof(wxString)) )
+        {
+            p = ps->data();
+            wxStringData *data = (wxStringData *)p - 1;
+            if ( ::IsBadReadPtr(data, sizeof(wxStringData)) ||
+                    ::IsBadReadPtr(p, sizeof(wxChar *)*data->nAllocLength) )
+            {
+                p = NULL; // don't touch this pointer with 10 feet pole
+            }
+        }
+
+        s << _T("(\"") << (p ? p : _T("???")) << _T(")\"");
     }
     else // any other UDT
 #endif // !wxUSE_STL