diff --git a/test/httplib.h b/test/httplib.h index ef97ef996..57b84ea81 100644 --- a/test/httplib.h +++ b/test/httplib.h @@ -2889,12 +2889,12 @@ 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, 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; } @@ -3756,9 +3756,9 @@ 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(), 2048); + detail::stream_line_reader line_reader(strm, buf.data(), buf.size()); if (!line_reader.getline()) { return false; }