From e318e0948a8b5845ab639ad469e1be0e2a414395 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 6 Mar 2018 19:40:50 +0000 Subject: [PATCH] Fix a few assertions that were found when using debug CRT --- .../engines/HardwareDisplayDrawingEngine.cpp | 20 +++++++++++++++---- src/openrct2-ui/windows/ServerList.cpp | 2 +- src/openrct2/object/StringTable.cpp | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp index ffaf289422..a0af60a7cd 100644 --- a/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp @@ -69,8 +69,14 @@ public: ~HardwareDisplayDrawingEngine() override { - SDL_DestroyTexture(_screenTexture); - SDL_DestroyTexture(_scaledScreenTexture); + if (_screenTexture != nullptr) + { + SDL_DestroyTexture(_screenTexture); + } + if (_scaledScreenTexture != nullptr) + { + SDL_DestroyTexture(_scaledScreenTexture); + } SDL_FreeFormat(_screenTextureFormat); SDL_DestroyRenderer(_sdlRenderer); } @@ -93,7 +99,10 @@ public: void Resize(uint32 width, uint32 height) override { - SDL_DestroyTexture(_screenTexture); + if (_screenTexture != nullptr) + { + SDL_DestroyTexture(_screenTexture); + } SDL_FreeFormat(_screenTextureFormat); SDL_RendererInfo rendererInfo = {}; @@ -128,7 +137,10 @@ public: if (smoothNN) { - SDL_DestroyTexture(_scaledScreenTexture); + if (_scaledScreenTexture != nullptr) + { + SDL_DestroyTexture(_scaledScreenTexture); + } char scaleQualityBuffer[4]; snprintf(scaleQualityBuffer, sizeof(scaleQualityBuffer), "%u", scaleQuality); diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 04c90cce80..097abf6277 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -567,7 +567,7 @@ static bool server_compare(const server_entry &a, const server_entry &b) } // Then by name - return String::Compare(a.name, b.name, true) <= 0; + return String::Compare(a.name, b.name, true) < 0; } static void sort_servers() diff --git a/src/openrct2/object/StringTable.cpp b/src/openrct2/object/StringTable.cpp index 0cb4955ce6..5b7ee08dd3 100644 --- a/src/openrct2/object/StringTable.cpp +++ b/src/openrct2/object/StringTable.cpp @@ -44,7 +44,7 @@ static bool StringIsBlank(const utf8 * str) { for (auto ch = str; *ch != '\0'; ch++) { - if (!isblank(*ch)) + if (!isblank((uint8)*ch)) { return false; }