You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void buffer<T>::append(const U* begin, const U* end) {
do {
auto count = to_unsigned(end - begin);
try_reserve(size_ + count);
auto free_cap = capacity_ - size_;
if (free_cap < count) count = free_cap;
std::uninitialized_copy_n(begin, count, make_checked(ptr_ + size_, count));
size_ += count;
begin += count;
} while (begin != end);
}
Since try_reserve can not increase the capacity being a fixed size buffer, the free_cap will always be 0, and the program hangs due to this issue.
void buffer<T>::append(const U* begin, const U* end) {
do {
auto count = to_unsigned(end - begin);
try_reserve(size_ + count);
auto free_cap = capacity_ - size_;
if(free_cap) {
if (free_cap < count) count = free_cap;
std::uninitialized_copy_n(begin, count, make_checked(ptr_ + size_, count));
}
size_ += count;
begin += count;
} while (begin != end);
}
Adding a check that free_cap is not 0 before we truncate count, and copy means that format_to_n will still report the needed buffer size to contain the string. this is consistent with behavior such as:
where Size of the result of format_to_n will report 5 even though it filled buffer with '1000'.
I'm unsure if free_cap can temporarily be 0 in some instances, in which case an alternative check may need to be performed that we are working on a fixed sized buffer.
The text was updated successfully, but these errors were encountered:
Doing:
will hang infinitely as the code here:
fmt/include/fmt/format.h
Line 606 in e29f93e
Since try_reserve can not increase the capacity being a fixed size buffer, the free_cap will always be 0, and the program hangs due to this issue.
Adding a check that free_cap is not 0 before we truncate count, and copy means that format_to_n will still report the needed buffer size to contain the string. this is consistent with behavior such as:
where Size of the result of format_to_n will report 5 even though it filled buffer with '1000'.
I'm unsure if free_cap can temporarily be 0 in some instances, in which case an alternative check may need to be performed that we are working on a fixed sized buffer.
The text was updated successfully, but these errors were encountered: