File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -146,7 +146,12 @@ private static bool SelectPlayerAndWorld(bool onlyPlayer = false)
146146 return false ;
147147 }
148148 int playerId = Utilities . FindPlayerId ( Conf . C . Player ) ;
149- var player = Main . PlayerList . Count > playerId ? Main . PlayerList [ playerId ] : null ;
149+ if ( playerId < 0 || playerId >= Main . PlayerList . Count )
150+ {
151+ Log . Error ( $ "Invalid player index { playerId } . Cannot autoload player.") ;
152+ return false ;
153+ }
154+ var player = Main . PlayerList [ playerId ] ;
150155
151156 if ( ClientDataJsonHelper . PlayerPath != null && ClientDataJsonHelper . ClientMode != ClientMode . FreshClient )
152157 {
@@ -174,7 +179,12 @@ private static bool SelectPlayerAndWorld(bool onlyPlayer = false)
174179 }
175180
176181 int worldId = Utilities . FindWorldId ( Conf . C . World ) ;
177- var world = Main . WorldList . Count > worldId ? Main . WorldList [ worldId ] : null ;
182+ if ( worldId < 0 || worldId >= Main . WorldList . Count )
183+ {
184+ Log . Error ( $ "Invalid world index { worldId } . Cannot autoload world.") ;
185+ return false ;
186+ }
187+ var world = Main . WorldList [ worldId ] ;
178188
179189 if ( ClientDataJsonHelper . WorldPath != null && ClientDataJsonHelper . ClientMode != ClientMode . FreshClient )
180190 {
You can’t perform that action at this time.
0 commit comments