]> git.saurik.com Git - wxWidgets.git/commitdiff
Corrected test for region validity in wxMSW wxRegion::DoOffset().
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 16 Dec 2011 19:47:55 +0000 (19:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 16 Dec 2011 19:47:55 +0000 (19:47 +0000)
Checking M_REGION is not enough as the region can be invalid (meaning
m_refData dereferenced inside M_REGION is NULL itself) and not just not
initialized, so it resulted in crashes and not just the expected assert
failure when wxRegion::Offset() was called for an invalid region.

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

src/msw/region.cpp

index fed4cda96b602a329a0911035ad94d90640d7a94..fece55e9c5e9357e0ceeec86bc44efa420e60191 100644 (file)
@@ -165,7 +165,8 @@ void wxRegion::Clear()
 
 bool wxRegion::DoOffset(wxCoord x, wxCoord y)
 {
-    wxCHECK_MSG( M_REGION, false, wxT("invalid wxRegion") );
+    const HRGN hrgn = GetHrgn();
+    wxCHECK_MSG( hrgn, false, wxT("invalid wxRegion") );
 
     if ( !x && !y )
     {
@@ -175,7 +176,7 @@ bool wxRegion::DoOffset(wxCoord x, wxCoord y)
 
     AllocExclusive();
 
-    if ( ::OffsetRgn(GetHrgn(), x, y) == ERROR )
+    if ( ::OffsetRgn(hrgn, x, y) == ERROR )
     {
         wxLogLastError(wxT("OffsetRgn"));