diff options
author | Pedro Rodrigues <pedro@onimail.net> | 2021-03-01 21:38:16 +0000 |
---|---|---|
committer | Pedro Rodrigues <pedro@onimail.net> | 2021-03-03 21:00:30 +0000 |
commit | a3a731ed92aec7a7a99b369d84d9f11fcbec5642 (patch) | |
tree | 27c3ea27727e7c4076e1b696ac716df71f4872e1 | |
parent | 864caf571164dea655a7c1f9d9b423195653dee2 (diff) |
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
-rw-r--r-- | core/io/http_client.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 18afdc678e..3863dce0f6 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -96,6 +96,11 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, 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; } |