From eea6f9fe279b3bf81c2e63da1c840c22bbd7ad6b Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 16 Nov 2021 09:36:21 +0100 Subject: [PATCH 1/2] Revert "Fix maybe initialized warning in httplib." This reverts commit 1f6fb238bad9d88f64929e06645185f3cd50fea2. --- test/httplib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/httplib.h b/test/httplib.h index ef97ef996..d9611df35 100644 --- a/test/httplib.h +++ b/test/httplib.h @@ -2892,9 +2892,9 @@ inline ssize_t Stream::write_format(const char *fmt, const Args &... args) { std::array buf; #if defined(_MSC_VER) && _MSC_VER < 1900 - auto sn = _snprintf_s(buf, bufsiz, 2048 - 1, fmt, args...); + auto sn = _snprintf_s(buf, bufsiz, buf.size() - 1, fmt, args...); #else - auto sn = snprintf(buf.data(), 2048 - 1, fmt, args...); + auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...); #endif if (sn <= 0) { return sn; } @@ -3758,7 +3758,7 @@ inline socket_t Client::create_client_socket() const { inline bool Client::read_response_line(Stream &strm, Response &res) { std::array buf; - detail::stream_line_reader line_reader(strm, buf.data(), 2048); + detail::stream_line_reader line_reader(strm, buf.data(), buf.size()); if (!line_reader.getline()) { return false; } From 0fcf166111acc33d80ae32291ca1e8ce06a01a2b Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 16 Nov 2021 09:39:56 +0100 Subject: [PATCH 2/2] Fix warning in httplib. The bug has been fixed upstream at yhirose/cpp-httplib#1091 This commit is a backport of the fix. --- test/httplib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/httplib.h b/test/httplib.h index d9611df35..57b84ea81 100644 --- a/test/httplib.h +++ b/test/httplib.h @@ -2889,7 +2889,7 @@ inline ssize_t Stream::write(const std::string &s) { template inline ssize_t Stream::write_format(const char *fmt, const Args &... args) { - std::array buf; + std::array buf{}; #if defined(_MSC_VER) && _MSC_VER < 1900 auto sn = _snprintf_s(buf, bufsiz, buf.size() - 1, fmt, args...); @@ -3756,7 +3756,7 @@ inline socket_t Client::create_client_socket() const { } inline bool Client::read_response_line(Stream &strm, Response &res) { - std::array buf; + std::array buf{}; detail::stream_line_reader line_reader(strm, buf.data(), buf.size());