From 974c115dff4da4a370a3569a3576cacb00eef7bb Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 9 Jun 2011 00:31:05 +0000 Subject: [PATCH] guard against nullptr git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67899 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/core/bitmap.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 5b0b5fa63a..408ab309bb 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1638,26 +1638,29 @@ bool wxMask::Create(const wxBitmap& bitmap) size_t size = m_bytesPerRow * m_height ; unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ; wxASSERT( destdatabase != NULL ) ; - - memset( destdatabase , 0 , size ) ; - unsigned char * srcdata = (unsigned char*) bitmap.GetRawAccess() ; - - for ( int y = 0 ; y < m_height ; ++y , destdatabase += m_bytesPerRow ) + + if ( destdatabase ) { - unsigned char *destdata = destdatabase ; - unsigned char r, g, b; + memset( destdatabase , 0 , size ) ; + unsigned char * srcdata = (unsigned char*) bitmap.GetRawAccess() ; - for ( int x = 0 ; x < m_width ; ++x ) + for ( int y = 0 ; y < m_height ; ++y , destdatabase += m_bytesPerRow ) { - srcdata++ ; - r = *srcdata++ ; - g = *srcdata++ ; - b = *srcdata++ ; + unsigned char *destdata = destdatabase ; + unsigned char r, g, b; - if ( ( r + g + b ) > 0x10 ) - *destdata++ = 0xFF ; - else - *destdata++ = 0x00 ; + for ( int x = 0 ; x < m_width ; ++x ) + { + srcdata++ ; + r = *srcdata++ ; + g = *srcdata++ ; + b = *srcdata++ ; + + if ( ( r + g + b ) > 0x10 ) + *destdata++ = 0xFF ; + else + *destdata++ = 0x00 ; + } } }