From ec56dfa35e4b20a3608afd1f9b52c155d8720ff2 Mon Sep 17 00:00:00 2001 From: yhirose Date: Mon, 15 Nov 2021 14:37:10 -0500 Subject: [PATCH] Fix #1085 (#1091) --- httplib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httplib.h b/httplib.h index 9b12f70..4268323 100644 --- a/httplib.h +++ b/httplib.h @@ -1487,10 +1487,10 @@ inline T Response::get_header_value(const char *key, size_t id) const { template inline ssize_t Stream::write_format(const char *fmt, const Args &...args) { const auto bufsiz = 2048; - std::array buf; + std::array buf{}; #if defined(_MSC_VER) && _MSC_VER < 1900 - auto sn = _snprintf_s(buf.data(), bufsiz - 1, buf.size() - 1, fmt, args...); + auto sn = _snprintf_s(buf.data(), bufsiz, _TRUNCATE, fmt, args...); #else auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...); #endif @@ -5673,7 +5673,7 @@ inline void ClientImpl::close_socket(Socket &socket) { inline bool ClientImpl::read_response_line(Stream &strm, const Request &req, Response &res) { - std::array buf; + std::array buf{}; detail::stream_line_reader line_reader(strm, buf.data(), buf.size());