From 5e6f709dbfb71bd61ff1de7892e8ef778030e153 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 30 Mar 2008 08:58:36 +0000 Subject: [PATCH] - Changed: When the screen is being deleted the 'screen' variable should be set to NULL before performing the delete. Otherwise, in some abnormal situations, it could happen that the destroyed screen object is still being accessed. - Fixed: V_Shutdown didn't set OF_YesReallyDelete before deleting screen. SVN r870 (trunk) --- docs/rh-log.txt | 5 +++++ src/sdl/hardware.cpp | 5 +++-- src/v_video.cpp | 15 ++++++++++----- src/win32/hardware.cpp | 5 +++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 5f7d8d695..373e262b9 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,9 @@ March 30, 2008 (Changes by Graf Zahl) +- Changed: When the screen is being deleted the 'screen' variable should be + set to NULL before performing the delete. Otherwise, in some abnormal + situations, it could happen that the destroyed screen object is still + being accessed. +- Fixed: V_Shutdown didn't set OF_YesReallyDelete before deleting screen. - Fixed: The HIRESTEX parser didn't check if a graphic specified in a remap command actually existed. - Fixed: My $Limit fix from yesterday didn't work because NearLimit was diff --git a/src/sdl/hardware.cpp b/src/sdl/hardware.cpp index cce3af149..856110033 100644 --- a/src/sdl/hardware.cpp +++ b/src/sdl/hardware.cpp @@ -53,9 +53,10 @@ void I_ShutdownGraphics () { if (screen) { - screen->ObjectFlags |= OF_YesReallyDelete; - delete screen; + DFrameBuffer *s = screen; screen = NULL; + s->ObjectFlags |= OF_YesReallyDelete; + delete s; } if (Video) delete Video, Video = NULL; diff --git a/src/v_video.cpp b/src/v_video.cpp index b90898eff..f23b9f3b0 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1642,9 +1642,12 @@ void V_Init2() float gamma = static_cast(screen)->Gamma; FFont *font = screen->Font; - screen->ObjectFlags |= OF_YesReallyDelete; - delete screen; - screen = NULL; + { + DFrameBuffer *s = screen; + screen = NULL; + s->ObjectFlags |= OF_YesReallyDelete; + delete s; + } I_InitGraphics(); I_ClosestResolution (&width, &height, 8); @@ -1665,10 +1668,12 @@ void V_Init2() void V_Shutdown() { - if (screen != NULL) + if (screen) { - delete screen; + DFrameBuffer *s = screen; screen = NULL; + s->ObjectFlags |= OF_YesReallyDelete; + delete s; } while (FFont::FirstFont != NULL) { diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 211cdafbf..bca4700fb 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -62,9 +62,10 @@ void I_ShutdownGraphics () { if (screen) { - screen->ObjectFlags |= OF_YesReallyDelete; - delete screen; + DFrameBuffer *s = screen; screen = NULL; + s->ObjectFlags |= OF_YesReallyDelete; + delete s; } if (Video) delete Video, Video = NULL;