diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-01-24 17:01:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-24 17:01:08 +0100 |
commit | fc09d783f4e8a6b8978c6971450f26e812268e67 (patch) | |
tree | 60df11f183f617b4e084fcc2b797517c5f78809a | |
parent | 61b79623274db1ed97ec6474084fbe803d947ada (diff) | |
parent | 17d4d3839ec03a25642b19f70b85d396c0d8a0ad (diff) |
Merge pull request #57122 from Faless/net/4.x_http_request_leak
-rw-r--r-- | scene/main/http_request.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 34cc4aceb8..65d210983e 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -442,30 +442,25 @@ void HTTPRequest::_request_done(int p_status, int p_code, const PackedStringArra is_compressed = false; } - const PackedByteArray *data = nullptr; - if (accept_gzip && is_compressed && p_data.size() > 0) { // Decompress request body - PackedByteArray *decompressed = memnew(PackedByteArray); - int result = Compression::decompress_dynamic(decompressed, body_size_limit, p_data.ptr(), p_data.size(), mode); + PackedByteArray decompressed; + int result = Compression::decompress_dynamic(&decompressed, body_size_limit, p_data.ptr(), p_data.size(), mode); if (result == OK) { - data = decompressed; + emit_signal(SNAME("request_completed"), p_status, p_code, p_headers, decompressed); + return; } else if (result == -5) { WARN_PRINT("Decompressed size of HTTP response body exceeded body_size_limit"); p_status = RESULT_BODY_SIZE_LIMIT_EXCEEDED; // Just return the raw data if we failed to decompress it - data = &p_data; } else { WARN_PRINT("Failed to decompress HTTP response body"); p_status = RESULT_BODY_DECOMPRESS_FAILED; // Just return the raw data if we failed to decompress it - data = &p_data; } - } else { - data = &p_data; } - emit_signal(SNAME("request_completed"), p_status, p_code, p_headers, *data); + emit_signal(SNAME("request_completed"), p_status, p_code, p_headers, p_data); } void HTTPRequest::_notification(int p_what) { |