mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 06:55:50 +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 <boost/multiprecision/cpp_int.hpp>
|
||||
#include <ed25519-donna/ed25519.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -186,14 +185,18 @@ PublicKey::PublicKey(PublicKey const& other) : size_(other.size_)
|
||||
{
|
||||
if (size_)
|
||||
std::memcpy(buf_, other.buf_, size_);
|
||||
};
|
||||
}
|
||||
|
||||
PublicKey&
|
||||
PublicKey::operator=(PublicKey const& other)
|
||||
{
|
||||
size_ = other.size_;
|
||||
if (size_)
|
||||
std::memcpy(buf_, other.buf_, size_);
|
||||
if (this != &other)
|
||||
{
|
||||
size_ = other.size_;
|
||||
if (size_)
|
||||
std::memcpy(buf_, other.buf_, size_);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user