浏览代码

Avoid overflow when calculating visible_cells

(cherry picked from commit 9e28df22a0195340016f3ec7271a0bd738c0e928)
Patrick Dawson 5 年之前
父节点
当前提交
8218170b3c
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      scene/resources/world_2d.cpp

+ 1 - 1
scene/resources/world_2d.cpp

@@ -228,7 +228,7 @@ struct SpatialIndexer2D {
 			List<VisibilityNotifier2D *> added;
 			List<VisibilityNotifier2D *> 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) {