-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
The code to check for rounding isn't tested:
charconv/include/boost/charconv/detail/parser.hpp
Lines 314 to 326 in 8fbdb8a
| if (offset > significand_buffer_size) | |
| { | |
| offset = significand_buffer_size - 1; | |
| i = significand_buffer_size; | |
| if (significand_buffer[offset] == '5' || | |
| significand_buffer[offset] == '6' || | |
| significand_buffer[offset] == '7' || | |
| significand_buffer[offset] == '8' || | |
| significand_buffer[offset] == '9') | |
| { | |
| round = true; | |
| } | |
| } |
I guess the initial idea was:
- Use a buffer 1 larger than the max significant digits (see also Fix off-by-one error in parser buffer size #243)
- If the buffer was full i.e.
offset == significand_buffer_size(can it ever be greater?) use the last digit for rounding
This IMO needs an additional overflow check in the rounding (the +=1)
Metadata
Metadata
Assignees
Labels
No labels