From 960bd4a5196885ebd4f9b33e17c779bb4b8f6ffe Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 22 Apr 2021 16:18:06 -0700 Subject: [PATCH] Add NULL checks and asserts to graphic options The game dereferences graphics.screenbuffer without checking it first... it's unlikely to happen, but the least we can to do be safe is to add a check and assert here. --- desktop_version/src/Input.cpp | 6 ++++++ desktop_version/src/Render.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 5af2fb31..3c713294 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -445,6 +445,12 @@ static void menuactionpress(void) map.nexttowercolour(); break; case Menu::graphicoptions: + if (graphics.screenbuffer == NULL) + { + SDL_assert(0 && "Screenbuffer is NULL!"); + break; + } + switch (game.currentmenuoption) { case 0: diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 3965595f..da3974ca 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -251,6 +251,12 @@ static void menurender(void) } break; case Menu::graphicoptions: + if (graphics.screenbuffer == NULL) + { + SDL_assert(0 && "Screenbuffer is NULL!"); + break; + } + switch (game.currentmenuoption) { case 0: