From ee94d6ddd98d63ee0d50e373f014ab01c4edea64 Mon Sep 17 00:00:00 2001 From: UTkarsh Maheshwari Date: Mon, 27 Nov 2017 19:57:15 +0530 Subject: [PATCH] Add a check for underflow in map --- src/map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/map.c b/src/map.c index bb8fb8f..f7f7b95 100644 --- a/src/map.c +++ b/src/map.c @@ -97,7 +97,8 @@ void map_set_tile(point_t point, map_tile_t tile) int convert_point_to_linear(point_t point) { - if (point.x < map -> size.x && point.y < map -> size.y) + if (point.x < map -> size.x && point.y < map -> size.y + && point.x > -1 && point.y > -1) return map -> size.x * point.y + point.x; return -1; }