This bug was caused by destroying textures after reinitializing the
window, which causes the SDL renderer to be destroyed and created
for the new window. Unfortunately, to destroy the old textures (which
were created using the previous renderer), the old renderer is used,
causing access to already free()'d memory.
To fix this bug, all textures are destroyed before the renderer is
destroyed (and re-created).
This bug caused regular crashes of the Windows version of the game
when switching between level sets that redefine the window size
(while no such crashes were observed with the Linux or Mac version).
{
// printf("::: init_video_buffer\n");
+ FreeAllImageTextures(); // needs old renderer to free the textures
+
InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
InitImageTextures();
}