Fix crash in OpenGL pyramid example if context creation fails

Initialize context pointers to null so that we don't delete uninitialized junk
later.

See #16910.

Closes https://github.com/wxWidgets/wxWidgets/pull/233
This commit is contained in:
Maarten Bent
2016-02-26 12:35:50 +01:00
committed by Vadim Zeitlin
parent 5ab459e4c7
commit e2fb055329
3 changed files with 7 additions and 1 deletions

View File

@@ -552,6 +552,7 @@ wxIMPLEMENT_CLASS(wxGLContext, wxObject);
wxGLContext::wxGLContext(wxGLCanvas *win,
const wxGLContext *other,
const wxGLContextAttrs *ctxAttrs)
: m_glContext(NULL)
{
const int* contextAttribs = NULL;
bool needsARB = false;
@@ -614,8 +615,11 @@ wxGLContext::wxGLContext(wxGLCanvas *win,
wxGLContext::~wxGLContext()
{
// note that it's ok to delete the context even if it's the current one
if ( m_glContext )
{
wglDeleteContext(m_glContext);
}
}
bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
{

View File

@@ -359,6 +359,7 @@ wxGLAttributes& wxGLAttributes::Defaults()
wxGLContext::wxGLContext(wxGLCanvas *win,
const wxGLContext *other,
const wxGLContextAttrs *ctxAttrs)
: m_glContext(NULL)
{
const int* contextAttribs = NULL;
int ctxSize = 0;

View File

@@ -454,6 +454,7 @@ wxIMPLEMENT_CLASS(wxGLContext, wxObject);
wxGLContext::wxGLContext(wxGLCanvas *win,
const wxGLContext *other,
const wxGLContextAttrs *ctxAttrs)
: m_glContext(NULL)
{
const int* contextAttribs = NULL;
Bool x11Direct = True;