소스 검색

RemoteConsole: prevent remove during iteration on close

Yuxiao Mao 6 달 전
부모
커밋
7c715cb0b9
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 2
      hrt/impl/RemoteConsole.hx

+ 5 - 2
hrt/impl/RemoteConsole.hx

@@ -79,9 +79,12 @@ class RemoteConsole {
 			sock.close();
 			sock = null;
 		}
-		for( s in connections )
-			s.close();
+		// prevent remove during iteration by c.close
+		var prevConnections = connections;
 		connections = [];
+		for( c in prevConnections ) {
+			c.close();
+		}
 		onClose();
 	}