[SDL] SDL2 error on iOS (doublefree)
tim at ngus.net
Tue Feb 7 10:37:25 PST 2012
On 07/02/2012 14:47, Tim Angus wrote:
> As I said before though the real fix is probably as follows:
>>> P.S. It could be argued that the real bug is that UIKit_AddDisplay
>>> create new copies of mode when assigning to display.desktop_mode and
>>> display.current_mode and thus avoid the icky double retain on mode. I'll
>>> probably have a look at this when I get a chance...
OK, I had a little chance to have a peek at this. Having had a closer
look at things, I believe the actual problem is that current_mode should
not be retained or owned at all. If you look at the rest of SDL it's
used as a reference to other modes rather than a mode in its own right.
It would probably help get its semantics clear if its type was actually
a pointer rather than a value i.e.:
- SDL_DisplayMode current_mode;
+ SDL_DisplayMode *current_mode;
The attached patch contains a bit of extra noise to centralise the
allocation of SDL_DisplayModeData, but in essence the fix is just to not
retain, allocate or free current_mode, and treat it as a weak reference
only. I haven't really had time to properly test this so YMMV, but I
think this is the correct route to take.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the SDL