Skip to content

Commit

Permalink
Fix crash in OpenGL pyramid example if context creation fails
Browse files Browse the repository at this point in the history
Initialize context pointers to null so that we don't delete uninitialized junk
later.

See wxWidgets#16910.

Closes wxWidgets#233
  • Loading branch information
MaartenBent authored and vadz committed Feb 26, 2016
1 parent 5ab459e commit e2fb055
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/msw/glcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -614,7 +615,10 @@ wxGLContext::wxGLContext(wxGLCanvas *win,
wxGLContext::~wxGLContext()
{
// note that it's ok to delete the context even if it's the current one
wglDeleteContext(m_glContext);
if ( m_glContext )
{
wglDeleteContext(m_glContext);
}
}

bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
Expand Down
1 change: 1 addition & 0 deletions src/osx/glcanvas_osx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/unix/glx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e2fb055

Please sign in to comment.