From 1078c389f993e9f2107af148eeb6c8a0311d3183 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sat, 18 Dec 2021 15:53:21 +0800 Subject: [PATCH] Fix crash when executing `TileMap.map_pattern` Validates the input reference. --- scene/2d/tile_map.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 084a5a520dc..2ad64768124 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -2104,6 +2104,7 @@ Ref TileMap::get_pattern(int p_layer, TypedArray p_coo } Vector2i TileMap::map_pattern(Vector2i p_position_in_tilemap, Vector2i p_coords_in_pattern, Ref p_pattern) { + ERR_FAIL_COND_V(p_pattern.is_null(), Vector2i()); ERR_FAIL_COND_V(!p_pattern->has_cell(p_coords_in_pattern), Vector2i()); Vector2i output = p_position_in_tilemap + p_coords_in_pattern;