mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd::util: Ensure null termination after all direct writes into string.
This commit is contained in:
parent
5a16a5ded9
commit
3683341aa9
1 changed files with 8 additions and 1 deletions
|
@ -174,7 +174,14 @@ string(const size_t &size,
|
|||
const_cast<char *>(ret.data()), ret.size()
|
||||
};
|
||||
|
||||
ret.resize(closure(buf));
|
||||
const size_t consumed
|
||||
{
|
||||
closure(buf)
|
||||
};
|
||||
|
||||
assert(consumed <= buffer::size(buf));
|
||||
data(buf)[consumed] = '\0';
|
||||
ret.resize(consumed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue