mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Common: fix a bug in BigNumber::AsByteArray that was causing incorrect output in 1/256 cases with explicit minSize (iff MSB zero)
This commit is contained in:
@@ -184,11 +184,11 @@ std::unique_ptr<uint8[]> BigNumber::AsByteArray(int32 minSize, bool littleEndian
|
||||
if (length > numBytes)
|
||||
memset((void*)array, 0, length);
|
||||
|
||||
BN_bn2bin(_bn, (unsigned char *)array);
|
||||
BN_bn2bin(_bn, array + (length-numBytes));
|
||||
|
||||
// openssl's BN stores data internally in big endian format, reverse if little endian desired
|
||||
if (littleEndian)
|
||||
std::reverse(array, array + numBytes);
|
||||
std::reverse(array, array + length);
|
||||
|
||||
std::unique_ptr<uint8[]> ret(array);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user