From 353117d484ea0017ba86b7d9bd000ddf93d8a014 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 10 Jan 2023 19:05:04 -0800 Subject: [PATCH] fix a crash in Screen when read or paint tile indices are negative --- library/modules/Screen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index 65817aa93..30e922708 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -208,7 +208,7 @@ static bool doSetTile(const Pen &pen, int x, int y, bool map) bool Screen::paintTile(const Pen &pen, int x, int y, bool map) { - if (!gps || !pen.valid()) return false; + if (!gps || !pen.valid() || x < 0 || y < 0) return false; doSetTile(pen, x, y, map); return true; @@ -301,7 +301,7 @@ static Pen doGetTile(int x, int y, bool map) Pen Screen::readTile(int x, int y, bool map) { - if (!gps) return Pen(0,0,0,-1); + if (!gps || x < 0 || y < 0) return Pen(0,0,0,-1); return doGetTile(x, y, map); }