Skip to content

Commit

Permalink
Add a check for underflow in map
Browse files Browse the repository at this point in the history
  • Loading branch information
coditva committed Nov 27, 2017
1 parent 66249cc commit ee94d6d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ee94d6d

Please sign in to comment.