浏览代码

Fixes HTTPClient::poll crash after connection is self-assigned

Haoyu Qiu 4 年之前
父节点
当前提交
8226cee8d8
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      core/io/http_client.cpp

+ 4 - 0
core/io/http_client.cpp

@@ -96,6 +96,10 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
 void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
 void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
 	ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object.");
 	ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object.");
 
 
+	if (connection == p_connection) {
+		return;
+	}
+
 	close();
 	close();
 	connection = p_connection;
 	connection = p_connection;
 	status = STATUS_CONNECTED;
 	status = STATUS_CONNECTED;