LibCrypto: Avoid UB in BigFraction::to_byte_string for 0/x fractions
This commit is contained in:
parent
bd26e5dce9
commit
2a2e31f2ed
Notes:
sideshowbarker
2024-07-17 06:09:44 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/2a2e31f2ed Pull-request: https://github.com/SerenityOS/serenity/pull/23123 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 1 additions and 1 deletions
|
@ -213,7 +213,7 @@ ByteString BigFraction::to_byte_string(unsigned rounding_threshold) const
|
|||
auto const remove_trailing_zeros = [](StringView value) -> StringView {
|
||||
auto n = value.length();
|
||||
VERIFY(n > 0);
|
||||
while (value.characters_without_null_termination()[n - 1] == '0')
|
||||
while (n > 0 && value.characters_without_null_termination()[n - 1] == '0')
|
||||
--n;
|
||||
return { value.characters_without_null_termination(), n };
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue