From b0c4316ebd9fd30c72f2cc72fab75772fe7c52c3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 20 Jul 2005 18:32:57 +0000 Subject: [PATCH] check the validity of wxString pointer itself too git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34896 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/debughlp.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/msw/debughlp.cpp b/src/msw/debughlp.cpp index cd8e486616..0f72ce897c 100644 --- a/src/msw/debughlp.cpp +++ b/src/msw/debughlp.cpp @@ -404,15 +404,19 @@ wxDbgHelpDLL::DumpUDT(PSYMBOL_INFO pSym, void *pVariable, unsigned level) // 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 = ps->data(); - wxStringData *data = (wxStringData *)p - 1; - if ( ::IsBadReadPtr(data, sizeof(wxStringData)) || - ::IsBadReadPtr(p, sizeof(wxChar *)*data->nAllocLength) ) + const wxChar *p = NULL; + if ( !::IsBadReadPtr(ps, sizeof(wxString)) ) { - p = _T("???"); + 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 << _T(")\""); + s << _T("(\"") << (p ? p : _T("???")) << _T(")\""); } else // any other UDT #endif // !wxUSE_STL -- 2.45.2