json and variant bug fixes
This commit is contained in:
parent
e7075f6b3a
commit
105948ea65
4 changed files with 12 additions and 4 deletions
|
|
@ -213,8 +213,7 @@ namespace fc
|
||||||
template<typename T>
|
template<typename T>
|
||||||
variant& operator=( T&& v )
|
variant& operator=( T&& v )
|
||||||
{
|
{
|
||||||
*this = variant( fc::forward<T>(v) );
|
return *this = variant( fc::forward<T>(v) );
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,16 @@
|
||||||
#include <fc/variant.hpp>
|
#include <fc/variant.hpp>
|
||||||
#include <fc/crypto/base64.hpp>
|
#include <fc/crypto/base64.hpp>
|
||||||
|
|
||||||
|
#include <fc/exception/exception.hpp>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
bigint::bigint( const char* bige, uint32_t l ) {
|
bigint::bigint( const char* bige, uint32_t l ) {
|
||||||
n = BN_bin2bn( (const unsigned char*)bige, l, NULL );
|
n = BN_bin2bn( (const unsigned char*)bige, l, NULL );
|
||||||
|
FC_ASSERT( n != nullptr );
|
||||||
}
|
}
|
||||||
bigint::bigint( const std::vector<char>& bige ) {
|
bigint::bigint( const std::vector<char>& bige ) {
|
||||||
n = BN_bin2bn( (const unsigned char*)bige.data(), bige.size(), NULL );
|
n = BN_bin2bn( (const unsigned char*)bige.data(), bige.size(), NULL );
|
||||||
|
FC_ASSERT( n != nullptr );
|
||||||
}
|
}
|
||||||
bigint::bigint( BIGNUM* in )
|
bigint::bigint( BIGNUM* in )
|
||||||
{
|
{
|
||||||
|
|
@ -151,6 +155,8 @@ namespace fc {
|
||||||
bigint& bigint::operator <<= ( uint32_t i )
|
bigint& bigint::operator <<= ( uint32_t i )
|
||||||
{
|
{
|
||||||
bigint tmp;
|
bigint tmp;
|
||||||
|
FC_ASSERT( tmp.n != nullptr );
|
||||||
|
FC_ASSERT( n != nullptr );
|
||||||
BN_lshift( tmp.n, n, i );
|
BN_lshift( tmp.n, n, i );
|
||||||
std::swap(*this,tmp);
|
std::swap(*this,tmp);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,9 @@ namespace fc
|
||||||
case 0x04: // ^D end of transmission
|
case 0x04: // ^D end of transmission
|
||||||
FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" );
|
FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" );
|
||||||
default:
|
default:
|
||||||
|
in.get(); //
|
||||||
ilog( "unhandled char '${c}' int ${int}", ("c", fc::string( &c, 1 ) )("int", int(c)) );
|
ilog( "unhandled char '${c}' int ${int}", ("c", fc::string( &c, 1 ) )("int", int(c)) );
|
||||||
|
return variant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return variant();
|
return variant();
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ void variant::clear()
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset( this, 0, sizeof(*this) );
|
set_variant_type( this, null_type );
|
||||||
}
|
}
|
||||||
|
|
||||||
variant::variant( const variant& v )
|
variant::variant( const variant& v )
|
||||||
|
|
@ -207,8 +207,9 @@ variant::~variant()
|
||||||
variant& variant::operator=( variant&& v )
|
variant& variant::operator=( variant&& v )
|
||||||
{
|
{
|
||||||
if( this == &v ) return *this;
|
if( this == &v ) return *this;
|
||||||
|
clear();
|
||||||
memcpy( (char*)this, (char*)&v, sizeof(v) );
|
memcpy( (char*)this, (char*)&v, sizeof(v) );
|
||||||
v.clear();
|
set_variant_type( &v, null_type );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue