prevent access to first element of vector when vector is empty when writing properties
This commit is contained in:
@@ -191,7 +191,8 @@ SIMPLE_BINARY(unsigned long);
|
||||
bool _swap=false) { \
|
||||
value_type tmp = _val; \
|
||||
size_t i, b = size_of(_val), N = value_type::size_; \
|
||||
if (_swap) for (i=0; i<N; ++i) \
|
||||
if (_swap) \
|
||||
for (i=0; i<N; ++i) \
|
||||
reverse_byte_order( tmp[i] ); \
|
||||
_os.write( (const char*)&tmp[0], b ); \
|
||||
return _os.good() ? b : 0; \
|
||||
@@ -372,6 +373,7 @@ struct binary< std::vector< T > > {
|
||||
else {
|
||||
auto bytes_of_vec = size_of(_v, false);
|
||||
bytes += bytes_of_vec;
|
||||
if (_v.size() > 0)
|
||||
_os.write( reinterpret_cast<const char*>(&_v[0]), bytes_of_vec);
|
||||
}
|
||||
return _os.good() ? bytes : 0;
|
||||
@@ -395,6 +397,7 @@ struct binary< std::vector< T > > {
|
||||
{
|
||||
auto bytes_of_vec = size_of(_v, false);
|
||||
bytes += bytes_of_vec;
|
||||
if (_v.size() > 0)
|
||||
_is.read( reinterpret_cast<char*>(&_v[0]), bytes_of_vec );
|
||||
}
|
||||
return _is.good() ? bytes : 0;
|
||||
|
||||
Reference in New Issue
Block a user