mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Properly handle self-assignment of PublicKey
This commit is contained in:
committed by
Nik Bougalis
parent
21a3f4a5b5
commit
6a9c270776
@@ -24,7 +24,6 @@
|
|||||||
#include <ripple/protocol/impl/secp256k1.h>
|
#include <ripple/protocol/impl/secp256k1.h>
|
||||||
#include <boost/multiprecision/cpp_int.hpp>
|
#include <boost/multiprecision/cpp_int.hpp>
|
||||||
#include <ed25519-donna/ed25519.h>
|
#include <ed25519-donna/ed25519.h>
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
@@ -186,14 +185,18 @@ PublicKey::PublicKey(PublicKey const& other) : size_(other.size_)
|
|||||||
{
|
{
|
||||||
if (size_)
|
if (size_)
|
||||||
std::memcpy(buf_, other.buf_, size_);
|
std::memcpy(buf_, other.buf_, size_);
|
||||||
};
|
}
|
||||||
|
|
||||||
PublicKey&
|
PublicKey&
|
||||||
PublicKey::operator=(PublicKey const& other)
|
PublicKey::operator=(PublicKey const& other)
|
||||||
{
|
{
|
||||||
size_ = other.size_;
|
if (this != &other)
|
||||||
if (size_)
|
{
|
||||||
std::memcpy(buf_, other.buf_, size_);
|
size_ = other.size_;
|
||||||
|
if (size_)
|
||||||
|
std::memcpy(buf_, other.buf_, size_);
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user