From 91ecf2b1679bd510794e92ce4ba01a856d57252c Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 24 Apr 2024 23:35:55 +0300 Subject: [PATCH] Fix level regions accessing outside map --- src/mkmaze.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mkmaze.c b/src/mkmaze.c index e16d7fbd6..5acf97cc6 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -363,6 +363,16 @@ place_lregion( hy = ROWNO - 1; } + /* clamp the area to the map */ + if (lx < 1) + lx = 1; + if (hx > COLNO - 1) + hx = COLNO - 1; + if (ly < 0) + ly = 0; + if (hy > ROWNO - 1) + hy = ROWNO - 1; + /* first a probabilistic approach */ oneshot = (lx == hx && ly == hy);