From 7cccbaa15ecae6099cf6520fe79e312666bd6f42 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 20 Sep 2014 22:07:52 +0000 Subject: [PATCH] Fix double release in wxGLCanvas code. The change in r77701 was partially wrong, we shouldn't release Objective-C object if initializing it failed. See #16555. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77750 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/glcanvas.mm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 4c933ab8f1..8783ef4f1c 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -98,15 +98,14 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) // available. const NSOpenGLPixelFormatAttribute attrsAccel[] = { NSOpenGLPFAAccelerated, 0 }; - WXGLPixelFormat testFormat = [NSOpenGLPixelFormat alloc]; - if ( [testFormat initWithAttributes: attrsAccel] ) + if ( WXGLPixelFormat testFormat = [[NSOpenGLPixelFormat alloc] + initWithAttributes: attrsAccel] ) { // Hardware acceleration is available, use it. data[p++] = NSOpenGLPFAAccelerated; + [testFormat release]; } - [testFormat release]; - const NSOpenGLPixelFormatAttribute *attribs; if ( !attribList ) {