From: Holger Schemel Date: Mon, 7 Jan 2019 15:20:39 +0000 (+0100) Subject: fixed potential crash bug (accessing already destroyed SDL renderer) X-Git-Tag: 4.1.2.0~61 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=38d9385eff4ea0edef250a3ee7068614f22c9c88;p=rocksndiamonds.git fixed potential crash bug (accessing already destroyed SDL renderer) 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). --- diff --git a/src/tools.c b/src/tools.c index 6763d611..459f85a7 100644 --- a/src/tools.c +++ b/src/tools.c @@ -9658,6 +9658,8 @@ void ChangeViewportPropertiesIfNeeded(void) { // printf("::: init_video_buffer\n"); + FreeAllImageTextures(); // needs old renderer to free the textures + InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); InitImageTextures(); }