0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02:00

ircd::util: Fix clamp for negative stream::tellp() to view empty.

This commit is contained in:
Jason Volk 2023-02-07 12:53:02 -08:00
parent fe0f398e14
commit 8387459369

View file

@ -92,10 +92,15 @@ inline string_view
view(stringstream &ss,
const const_buffer &buf)
{
const auto tell
{
std::min(size_t(ss.tellp()), size(buf))
};
const size_t tell
(
std::clamp
(
ssize_t(ss.tellp()),
ssize_t(0),
ssize_t(size(buf))
)
);
ss.flush();
ss.rdbuf()->pubsync();