From de69bbd661dd3c4074e123de32b359bf4958cc1f Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 19 May 2020 21:25:27 +0200 Subject: [PATCH] Guard against illegal access --- src/openrct2/core/Imaging.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openrct2/core/Imaging.h b/src/openrct2/core/Imaging.h index 5da84a02e5..3e4824d372 100644 --- a/src/openrct2/core/Imaging.h +++ b/src/openrct2/core/Imaging.h @@ -35,8 +35,12 @@ struct GamePalette { PaletteBGRA Colour[PALETTE_SIZE]; - const PaletteBGRA& operator[](uint16_t idx) const + const PaletteBGRA operator[](uint16_t idx) const { + assert(idx < PALETTE_SIZE); + if (idx >= PALETTE_SIZE) + return {}; + return Colour[idx]; }