mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
Merge pull request #967 from brain5lug/openssl
missed self assigment check for EDDSAPoint
This commit is contained in:
commit
8c09a7429c
|
@ -363,31 +363,43 @@ namespace crypto
|
||||||
// EdDSA
|
// EdDSA
|
||||||
struct EDDSAPoint
|
struct EDDSAPoint
|
||||||
{
|
{
|
||||||
BIGNUM * x, * y;
|
BIGNUM * x {nullptr};
|
||||||
BIGNUM * z, * t; // projective coordinates
|
BIGNUM * y {nullptr};
|
||||||
EDDSAPoint (): x(nullptr), y(nullptr), z(nullptr), t(nullptr) {};
|
BIGNUM * z {nullptr};
|
||||||
EDDSAPoint (const EDDSAPoint& other): x(nullptr), y(nullptr), z(nullptr), t(nullptr)
|
BIGNUM * t {nullptr}; // projective coordinates
|
||||||
{ *this = other; };
|
|
||||||
EDDSAPoint (EDDSAPoint&& other): x(nullptr), y(nullptr), z(nullptr), t(nullptr)
|
EDDSAPoint () {}
|
||||||
{ *this = std::move (other); };
|
EDDSAPoint (const EDDSAPoint& other) { *this = other; }
|
||||||
EDDSAPoint (BIGNUM * x1, BIGNUM * y1, BIGNUM * z1 = nullptr, BIGNUM * t1 = nullptr): x(x1), y(y1), z(z1), t(t1) {};
|
EDDSAPoint (EDDSAPoint&& other) { *this = std::move (other); }
|
||||||
~EDDSAPoint () { BN_free (x); BN_free (y); BN_free(z); BN_free(t); };
|
EDDSAPoint (BIGNUM * x1, BIGNUM * y1, BIGNUM * z1 = nullptr, BIGNUM * t1 = nullptr)
|
||||||
|
: x(x1)
|
||||||
|
, y(y1)
|
||||||
|
, z(z1)
|
||||||
|
, t(t1)
|
||||||
|
{}
|
||||||
|
~EDDSAPoint () { BN_free (x); BN_free (y); BN_free(z); BN_free(t); }
|
||||||
|
|
||||||
EDDSAPoint& operator=(EDDSAPoint&& other)
|
EDDSAPoint& operator=(EDDSAPoint&& other)
|
||||||
{
|
{
|
||||||
if (x) BN_free (x); x = other.x; other.x = nullptr;
|
if (this != &other)
|
||||||
if (y) BN_free (y); y = other.y; other.y = nullptr;
|
{
|
||||||
if (z) BN_free (z); z = other.z; other.z = nullptr;
|
BN_free (x); x = other.x; other.x = nullptr;
|
||||||
if (t) BN_free (t); t = other.t; other.t = nullptr;
|
BN_free (y); y = other.y; other.y = nullptr;
|
||||||
|
BN_free (z); z = other.z; other.z = nullptr;
|
||||||
|
BN_free (t); t = other.t; other.t = nullptr;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
EDDSAPoint& operator=(const EDDSAPoint& other)
|
EDDSAPoint& operator=(const EDDSAPoint& other)
|
||||||
{
|
{
|
||||||
if (x) BN_free (x); x = other.x ? BN_dup (other.x) : nullptr;
|
if (this != &other)
|
||||||
if (y) BN_free (y); y = other.y ? BN_dup (other.y) : nullptr;
|
{
|
||||||
if (z) BN_free (z); z = other.z ? BN_dup (other.z) : nullptr;
|
BN_free (x); x = other.x ? BN_dup (other.x) : nullptr;
|
||||||
if (t) BN_free (t); t = other.t ? BN_dup (other.t) : nullptr;
|
BN_free (y); y = other.y ? BN_dup (other.y) : nullptr;
|
||||||
|
BN_free (z); z = other.z ? BN_dup (other.z) : nullptr;
|
||||||
|
BN_free (t); t = other.t ? BN_dup (other.t) : nullptr;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ namespace util
|
||||||
template<class T>
|
template<class T>
|
||||||
class MemoryPool
|
class MemoryPool
|
||||||
{
|
{
|
||||||
|
BOOST_STATIC_ASSERT_MSG(sizeof(T) >= sizeof(void*), "size cannot be less that general pointer size");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MemoryPool (): m_Head (nullptr) {}
|
MemoryPool (): m_Head (nullptr) {}
|
||||||
|
|
Loading…
Reference in a new issue