🐛 fixed a logical error

Treated the size of the range as the number of thousand separators.
This logical error yielded a negative value for written_bytes and
eventually an infinite loop, as written_bytes was converted to an
unsigned value.
This commit is contained in:
Niels Lohmann 2017-02-28 11:45:38 +01:00
parent af070744ae
commit fc48b8ac2b
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
2 changed files with 4 additions and 2 deletions

View file

@ -6648,7 +6648,8 @@ class basic_json
{
const auto end = std::remove(m_buf.begin(), m_buf.begin() + written_bytes, thousands_sep);
std::fill(end, m_buf.end(), '\0');
written_bytes -= (m_buf.end() - end);
assert((end - m_buf.begin()) <= written_bytes);
written_bytes = (end - m_buf.begin());
}
// convert decimal point to '.'

View file

@ -6648,7 +6648,8 @@ class basic_json
{
const auto end = std::remove(m_buf.begin(), m_buf.begin() + written_bytes, thousands_sep);
std::fill(end, m_buf.end(), '\0');
written_bytes -= (m_buf.end() - end);
assert((end - m_buf.begin()) <= written_bytes);
written_bytes = (end - m_buf.begin());
}
// convert decimal point to '.'