mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::util: Truncate when stream's tellp is out of range.
This commit is contained in:
parent
0a3db57bc2
commit
9b703f9915
1 changed files with 6 additions and 2 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue