Przeglądaj źródła

Portals - fix crash when logging link room names

The checking for link room IDs was checking for less than size(), but was not correctly checking for -1,
and therefore reading outside the array range. This PR fixes this.
lawnjelly 4 lat temu
rodzic
commit
ef894c0966
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      scene/3d/room_manager.cpp

+ 1 - 1
scene/3d/room_manager.cpp

@@ -848,7 +848,7 @@ void RoomManager::_third_pass_rooms(const LocalVector<Portal *> &p_portals) {
 				int linked_room_id = (portal_links_out) ? portal._linkedroom_ID[1] : portal._linkedroom_ID[0];
 
 				// this shouldn't be out of range, but just in case
-				if (linked_room_id < _rooms.size()) {
+				if ((linked_room_id >= 0) && (linked_room_id < _rooms.size())) {
 					Room *linked_room = _rooms[linked_room_id];
 
 					String portal_link_room_name = _find_name_before(linked_room, "-room", true);