mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
LibCrypto: Fix to_base10() for zero-value BigIntegers
All the magic is happening in a "while != 0" loop, so we ended up with an empty string for zero-value BigIntegers. Now we just check that upfront and return early.
This commit is contained in:
parent
5b88aa8e96
commit
75b4cc13a0
Notes:
sideshowbarker
2024-07-19 05:46:41 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/75b4cc13a08 Pull-request: https://github.com/SerenityOS/serenity/pull/2509 Reviewed-by: https://github.com/alimpfard
1 changed files with 3 additions and 0 deletions
|
@ -80,6 +80,9 @@ UnsignedBigInteger UnsignedBigInteger::from_base10(const String& str)
|
|||
|
||||
String UnsignedBigInteger::to_base10() const
|
||||
{
|
||||
if (*this == UnsignedBigInteger { 0 })
|
||||
return "0";
|
||||
|
||||
StringBuilder builder;
|
||||
UnsignedBigInteger temp(*this);
|
||||
UnsignedBigInteger quotient;
|
||||
|
|
Loading…
Add table
Reference in a new issue