sdl2_frt/src
Sam Lantinga 356c2eadf4 Fixed bug 3544 - Memory freeing bug in SDL_DestroyRenderer/SDL_DestroyTexture
felix

Here's a snippet of SDL_DestroyRenderer from hg revision 10746:7540ff5d0e0e:

    SDL_Texture *texture = NULL;
    SDL_Texture *nexttexture = NULL;
    /* ... */
    for (texture = renderer->textures; texture; texture = nexttexture) {
        nexttexture = texture->next;
        SDL_DestroyTexture(texture);
    }

SDL_DestroyTexture removes the texture from the linked list pointed to by the renderer and ends up calling SDL_DestroyTextureInternal, which contains this:

    if (texture->native) {
        SDL_DestroyTexture(texture->native);
    }

If it happens that texture->native is an alias of nexttexture two stack frames up, SDL_DestroyRenderer will end up trying to destroy an already freed texture. I've had this very situation happen in dosemu2.

Bug introduced in revision 10650:a8253d439914, which has a somewhat ironic description of "Fixed all known static analysis bugs"...
2017-01-06 00:32:06 -08:00
..
atomic Updated copyright for 2017 2017-01-01 18:33:28 -08:00
audio haiku: Patched to compile. 2017-01-06 03:15:27 -05:00
core Fixed bug 3546 - SDL_EVDEV_is_console() uses type of wrong size when calling ioctl 2017-01-05 23:26:13 -08:00
cpuinfo Updated copyright for 2017 2017-01-01 18:33:28 -08:00
dynapi Added SDL_JoystickGetAxisInitialState() to get a joystick axis' initial value. 2017-01-04 10:28:07 -08:00
events Updated copyright for 2017 2017-01-01 18:33:28 -08:00
file Updated copyright for 2017 2017-01-01 18:33:28 -08:00
filesystem Updated copyright for 2017 2017-01-01 18:33:28 -08:00
haptic Updated copyright for 2017 2017-01-01 18:33:28 -08:00
joystick Fixed build warning on Haiku 2017-01-05 02:53:29 -08:00
libm Updated copyright for 2017 2017-01-01 18:33:28 -08:00
loadso Updated copyright for 2017 2017-01-01 18:33:28 -08:00
main Updated copyright for 2017 2017-01-01 18:33:28 -08:00
power Updated copyright for 2017 2017-01-01 18:33:28 -08:00
render Fixed bug 3544 - Memory freeing bug in SDL_DestroyRenderer/SDL_DestroyTexture 2017-01-06 00:32:06 -08:00
stdlib Updated copyright for 2017 2017-01-01 18:33:28 -08:00
test Updated copyright for 2017 2017-01-01 18:33:28 -08:00
thread Updated copyright for 2017 2017-01-01 18:33:28 -08:00
timer Updated copyright for 2017 2017-01-01 18:33:28 -08:00
video Fixed signedness issue when blitting on a big endian platform, as reported by capehill 2017-01-05 08:16:39 -08:00
SDL_assert_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_assert.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_dataqueue.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_dataqueue.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_error_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_error.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_hints.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_internal.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_log.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00