From 9e28df22a0195340016f3ec7271a0bd738c0e928 Mon Sep 17 00:00:00 2001 From: Patrick Dawson Date: Mon, 13 Jul 2020 01:39:39 +0200 Subject: Avoid overflow when calculating visible_cells --- scene/resources/world_2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scene/resources') diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 1c753fdb91..d2bc2bea31 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -211,7 +211,7 @@ struct SpatialIndexer2D { List added; List removed; - int visible_cells = (end.x - begin.x) * (end.y - begin.y); + uint64_t visible_cells = (uint64_t)(end.x - begin.x) * (uint64_t)(end.y - begin.y); if (visible_cells > 10000) { //well you zoomed out a lot, it's your problem. To avoid freezing in the for loops below, we'll manually check cell by cell -- cgit v1.2.3