From b2730fb3f8a00dd142b53e1651d2d83046dead31 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sat, 6 Jul 2024 12:20:03 -0400 Subject: [PATCH] pie_AssignTexture: Sanity check --- lib/ivis_opengl/tex.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ivis_opengl/tex.cpp b/lib/ivis_opengl/tex.cpp index 39c235d575f..a566a903b7e 100644 --- a/lib/ivis_opengl/tex.cpp +++ b/lib/ivis_opengl/tex.cpp @@ -106,6 +106,12 @@ size_t pie_ReserveTexture(const char *filename, const size_t& width, const size_ void pie_AssignTexture(size_t page, gfx_api::texture* texture) { + if (page >= _TEX_PAGE.size()) + { + debug(LOG_ERROR, "Invalid page (%zu), number of texpages=%zu", page, _TEX_PAGE.size()); + delete texture; + return; + } if (_TEX_PAGE[page].id) delete _TEX_PAGE[page].id; _TEX_PAGE[page].id = texture;