mirror of
https://github.com/matrix-construct/construct
synced 2024-07-11 13:08:35 +02:00
ircd::util: Ensure null termination after all direct writes into string.
This commit is contained in:
parent
5a16a5ded9
commit
3683341aa9
|
@ -174,7 +174,14 @@ string(const size_t &size,
|
||||||
const_cast<char *>(ret.data()), ret.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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue