Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
ca537dea
Commit
ca537dea
authored
Jan 27, 2020
by
Haoyu Qiu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes invalid read when using fill tool in empty tilemap
parent
3ca87b9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
tile_map_editor_plugin.cpp
editor/plugins/tile_map_editor_plugin.cpp
+6
-5
No files found.
editor/plugins/tile_map_editor_plugin.cpp
View file @
ca537dea
...
...
@@ -627,13 +627,14 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
if
(
r
!=
bucket_cache_rect
)
_clear_bucket_cache
();
// Cache grid is not initialized
if
(
bucket_cache_visited
==
0
)
{
if
(
bucket_cache_visited
==
NULL
)
{
bucket_cache_visited
=
new
bool
[
area
];
invalidate_cache
=
true
;
}
// Tile ID changed or position wasn't visited by the previous fill
int
loc
=
(
p_start
.
x
-
r
.
position
.
x
)
+
(
p_start
.
y
-
r
.
position
.
y
)
*
r
.
get_size
().
x
;
if
(
prev_id
!=
bucket_cache_tile
||
!
bucket_cache_visited
[
loc
])
{
const
int
loc
=
(
p_start
.
x
-
r
.
position
.
x
)
+
(
p_start
.
y
-
r
.
position
.
y
)
*
r
.
get_size
().
x
;
const
bool
in_range
=
0
<=
loc
&&
loc
<
area
;
if
(
prev_id
!=
bucket_cache_tile
||
(
in_range
&&
!
bucket_cache_visited
[
loc
]))
{
invalidate_cache
=
true
;
}
if
(
invalidate_cache
)
{
...
...
@@ -893,7 +894,7 @@ void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Po
void
TileMapEditor
::
_clear_bucket_cache
()
{
if
(
bucket_cache_visited
)
{
delete
[]
bucket_cache_visited
;
bucket_cache_visited
=
0
;
bucket_cache_visited
=
NULL
;
}
}
...
...
@@ -1924,7 +1925,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
transpose
=
false
;
bucket_cache_tile
=
-
1
;
bucket_cache_visited
=
0
;
bucket_cache_visited
=
NULL
;
invalid_cell
.
resize
(
1
);
invalid_cell
.
write
[
0
]
=
TileMap
::
INVALID_CELL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment