diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2021-12-18 15:53:21 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2021-12-18 15:53:21 +0800 |
commit | 1078c389f993e9f2107af148eeb6c8a0311d3183 (patch) | |
tree | 052f55579f15133801bd1065a2d754004db0d35a | |
parent | b0e93711b36bae3d2bb3a7e9a4a88faf055499fb (diff) |
Fix crash when executing `TileMap.map_pattern`
Validates the input reference.
-rw-r--r-- | scene/2d/tile_map.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 084a5a520d..2ad6476812 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -2104,6 +2104,7 @@ Ref<TileMapPattern> TileMap::get_pattern(int p_layer, TypedArray<Vector2i> p_coo } Vector2i TileMap::map_pattern(Vector2i p_position_in_tilemap, Vector2i p_coords_in_pattern, Ref<TileMapPattern> 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; |