Fix an overflow in format_to_n (#2029)

This commit is contained in:
Victor Zverovich
2020-11-18 06:43:47 -08:00
parent df66516ed3
commit b8957f50c3
2 changed files with 6 additions and 1 deletions

View File

@@ -761,7 +761,7 @@ class fixed_buffer_traits {
explicit fixed_buffer_traits(size_t limit) : limit_(limit) {}
size_t count() const { return count_; }
size_t limit(size_t size) {
size_t n = limit_ - count_;
size_t n = limit_ > count_ ? limit_ - count_ : 0;
count_ += size;
return size < n ? size : n;
}