We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2629 - [Patch] Mac: crash when calling SDL_DestroyWindow with an active OpenGL context
Summary: [Patch] Mac: crash when calling SDL_DestroyWindow with an active OpenGL context
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Mac OS X (All)
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-06 01:49 UTC by Alex Szpakowski
Modified: 2014-07-07 17:33 UTC (History)
0 users

See Also:


Attachments
Patch to fix SDL_DestroyWindow crashing (556 bytes, patch)
2014-07-06 01:49 UTC, Alex Szpakowski
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Szpakowski 2014-07-06 01:49:23 UTC
Created attachment 1736 [details]
Patch to fix SDL_DestroyWindow crashing

Since this commit https://hg.libsdl.org/SDL/rev/1519c462cee6 , calling SDL_DestroyWindow will crash the program if the window has an active OpenGL context.

This is because the Cocoa_DestroyWindow code sets the window's driverdata to NULL and then calls [context setWindow:NULL], which tries to access the window's driverdata, resulting in a null pointer dereference.

I have attached a patch which fixes the issue by moving the line which sets the driverdata to NULL to after the lines which call functions that use the driverdata pointer.
Comment 1 Sam Lantinga 2014-07-07 17:33:57 UTC
Nice catch, thanks!
https://hg.libsdl.org/SDL/rev/7753e4fd3d1d