Преглед изворни кода

Fix crash on HTTPClient::poll method

The problem happened because `poll` assumed that when the SSL flag was
true, the `connection` would be a subclass of StreamPeerSSL. However
that invariant could be broken by calling HTTPClient::set_connection
with a `connection` that is not a subclass of StreamPeerSSL.

Fixes #46138

(cherry picked from commit a3a731ed92aec7a7a99b369d84d9f11fcbec5642)
Pedro Rodrigues пре 4 година
родитељ
комит
eec2731eb2
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      core/io/http_client.cpp

+ 5 - 0
core/io/http_client.cpp

@@ -100,6 +100,11 @@ 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.");
 
+	if (ssl) {
+		ERR_FAIL_NULL_MSG(Object::cast_to<StreamPeerSSL>(p_connection.ptr()),
+				"Connection is not a reference to a valid StreamPeerSSL object.");
+	}
+
 	if (connection == p_connection) {
 		return;
 	}