Don't leave dangling pointers

This commit is contained in:
Marek Roszko 2020-11-07 09:48:59 -05:00
parent 7bc83b8c4f
commit df49e0bb0d
1 changed files with 10 additions and 1 deletions

View File

@ -1218,6 +1218,9 @@ CAIRO_GAL::CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions,
validCompositor = false; validCompositor = false;
SetTarget( TARGET_NONCACHED ); SetTarget( TARGET_NONCACHED );
bitmapBuffer = nullptr;
wxOutput = nullptr;
parentWindow = aParent; parentWindow = aParent;
mouseListener = aMouseListener; mouseListener = aMouseListener;
paintListener = aPaintListener; paintListener = aPaintListener;
@ -1464,7 +1467,10 @@ void CAIRO_GAL::allocateBitmaps()
stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth ); stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth );
bufferSize = stride * screenSize.y; bufferSize = stride * screenSize.y;
bitmapBuffer = new unsigned char[bufferSize * 4]; wxASSERT( bitmapBuffer == nullptr );
bitmapBuffer = new unsigned char[bufferSize * 4];
wxASSERT( wxOutput == nullptr );
wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y]; wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y];
} }
@ -1472,7 +1478,10 @@ void CAIRO_GAL::allocateBitmaps()
void CAIRO_GAL::deleteBitmaps() void CAIRO_GAL::deleteBitmaps()
{ {
delete[] bitmapBuffer; delete[] bitmapBuffer;
bitmapBuffer = nullptr;
delete[] wxOutput; delete[] wxOutput;
wxOutput = nullptr;
} }