From e2ca506e2393d8bdfbc005d526438ac3246da779 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 1 Aug 2023 00:13:09 -0400 Subject: [PATCH] Fix off-by-one error in Textures::cleanup() In a ASCII-only configuration, I was seeing `textures.raws.size() == 164` and `texpos_end == 164`. This resulted in reading one item past the end of the vector. This may not be occurring in configurations with graphics enabled, or Windows/WINE may be more permissive. --- library/modules/Textures.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/modules/Textures.cpp b/library/modules/Textures.cpp index 46dd0a4c5..ae0836ffe 100644 --- a/library/modules/Textures.cpp +++ b/library/modules/Textures.cpp @@ -175,7 +175,7 @@ void Textures::cleanup() { auto & textures = enabler->textures; auto &raws = textures.raws; - size_t texpos_end = g_dfhack_logo_texpos_start + g_num_dfhack_textures; + size_t texpos_end = g_dfhack_logo_texpos_start + g_num_dfhack_textures - 1; for (size_t idx = g_dfhack_logo_texpos_start; idx <= texpos_end; ++idx) { DFSDL_FreeSurface((SDL_Surface *)raws[idx]); raws[idx] = NULL;