0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd::util: Truncate when stream's tellp is out of range.

This commit is contained in:
Jason Volk 2019-01-19 17:01:53 -08:00
parent 0a3db57bc2
commit 9b703f9915

View file

@ -66,12 +66,16 @@ string_view
view(stringstream &ss,
const const_buffer &buf)
{
assert(size_t(ss.tellp()) <= size(buf));
const auto tell
{
std::min(size_t(ss.tellp()), size(buf))
};
ss.flush();
ss.rdbuf()->pubsync();
const string_view ret
{
data(buf), size_t(ss.tellp())
data(buf), tell
};
assert(size(ret) <= size(buf));