diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index 7cdc96c..3e7b095 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -213,8 +213,7 @@ namespace fc template variant& operator=( T&& v ) { - *this = variant( fc::forward(v) ); - return *this; + return *this = variant( fc::forward(v) ); } template diff --git a/src/crypto/bigint.cpp b/src/crypto/bigint.cpp index d13675e..0682992 100644 --- a/src/crypto/bigint.cpp +++ b/src/crypto/bigint.cpp @@ -4,12 +4,16 @@ #include #include +#include + namespace fc { bigint::bigint( const char* bige, uint32_t l ) { n = BN_bin2bn( (const unsigned char*)bige, l, NULL ); + FC_ASSERT( n != nullptr ); } bigint::bigint( const std::vector& bige ) { n = BN_bin2bn( (const unsigned char*)bige.data(), bige.size(), NULL ); + FC_ASSERT( n != nullptr ); } bigint::bigint( BIGNUM* in ) { @@ -151,6 +155,8 @@ namespace fc { bigint& bigint::operator <<= ( uint32_t i ) { bigint tmp; + FC_ASSERT( tmp.n != nullptr ); + FC_ASSERT( n != nullptr ); BN_lshift( tmp.n, n, i ); std::swap(*this,tmp); return *this; diff --git a/src/io/json.cpp b/src/io/json.cpp index d9028a4..c8d96ba 100644 --- a/src/io/json.cpp +++ b/src/io/json.cpp @@ -298,7 +298,9 @@ namespace fc case 0x04: // ^D end of transmission FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" ); default: + in.get(); // ilog( "unhandled char '${c}' int ${int}", ("c", fc::string( &c, 1 ) )("int", int(c)) ); + return variant(); } } return variant(); diff --git a/src/variant.cpp b/src/variant.cpp index 86ee07d..d4c69ad 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -166,7 +166,7 @@ void variant::clear() default: break; } - memset( this, 0, sizeof(*this) ); + set_variant_type( this, null_type ); } variant::variant( const variant& v ) @@ -207,8 +207,9 @@ variant::~variant() variant& variant::operator=( variant&& v ) { if( this == &v ) return *this; + clear(); memcpy( (char*)this, (char*)&v, sizeof(v) ); - v.clear(); + set_variant_type( &v, null_type ); return *this; }