From d24e13e6051749f771634d946a1d8519b88ae005 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Thu, 17 Apr 2025 10:32:14 +0200 Subject: [PATCH] Fixed HttpsClient::flush logic - Don't write empty buffers - Don't write if an error was returned --- src/base/net/https/HttpsClient.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/base/net/https/HttpsClient.cpp b/src/base/net/https/HttpsClient.cpp index e901b1e0..8cd9099a 100644 --- a/src/base/net/https/HttpsClient.cpp +++ b/src/base/net/https/HttpsClient.cpp @@ -189,10 +189,12 @@ void xmrig::HttpsClient::flush(bool close) } char *data = nullptr; - const size_t size = BIO_get_mem_data(m_write, &data); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) - std::string body(data, size); + const long size = BIO_get_mem_data(m_write, &data); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) + std::string body(data, (size > 0) ? size : 0); (void) BIO_reset(m_write); - HttpContext::write(std::move(body), close); + if (!body.empty()) { + HttpContext::write(std::move(body), close); + } }