From 5b130f274edba5827fa68523def9e631824be5b8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 16 Dec 2011 19:47:55 +0000 Subject: [PATCH] Corrected test for region validity in wxMSW wxRegion::DoOffset(). 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/msw/region.cpp b/src/msw/region.cpp index fed4cda96b..fece55e9c5 100644 --- a/src/msw/region.cpp +++ b/src/msw/region.cpp @@ -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")); -- 2.45.2