serialization: forbid reading 0 varints from empty data

this could plausibly be useful as a tail compression scheme,
but every other varint loading code treats 0 bytes read as an
error, and it goes with the principle of least surprise.
This commit is contained in:
Crypto City 2022-07-24 16:30:43 +00:00
parent 4552e18249
commit 837ad9515e

View File

@ -157,7 +157,7 @@ struct binary_archive<false> : public binary_archive_base<false>
{
auto current = bytes_.cbegin();
auto end = bytes_.cend();
good_ &= (0 <= tools::read_varint(current, end, v));
good_ &= (0 < tools::read_varint(current, end, v));
current = std::min(current, bytes_.cend());
bytes_ = {current, std::size_t(bytes_.cend() - current)};
}