From be4d480174e22e97e6f0c68fa86ab3d749812b42 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 18 Jan 2019 12:29:38 -0500 Subject: [PATCH 1/3] Remove unnecessary asserts --- include/fc/container/flat.hpp | 2 -- include/fc/io/raw.hpp | 6 ------ include/fc/io/raw_fwd.hpp | 2 -- include/fc/io/raw_variant.hpp | 1 - 4 files changed, 11 deletions(-) diff --git a/include/fc/container/flat.hpp b/include/fc/container/flat.hpp index 5cac53e..5012c5d 100644 --- a/include/fc/container/flat.hpp +++ b/include/fc/container/flat.hpp @@ -25,7 +25,6 @@ namespace fc { --_max_depth; unsigned_int size; unpack( s, size, _max_depth ); value.clear(); - FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE ); value.reserve( std::min( size.value, FC_MAX_PREALLOC_SIZE ) ); for( uint32_t i = 0; i < size.value; ++i ) { @@ -53,7 +52,6 @@ namespace fc { --_max_depth; unsigned_int size; unpack( s, size, _max_depth ); value.clear(); - FC_ASSERT( size.value*(sizeof(K)+sizeof(V)) < MAX_ARRAY_ALLOC_SIZE ); value.reserve( std::min( size.value, FC_MAX_PREALLOC_SIZE ) ); for( uint32_t i = 0; i < size.value; ++i ) { diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index a2ecbc8..15c6bad 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -261,7 +261,6 @@ namespace fc { template inline void unpack( Stream& s, std::vector& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); unsigned_int size; fc::raw::unpack( s, size, _max_depth - 1 ); - FC_ASSERT( size.value < MAX_ARRAY_ALLOC_SIZE ); value.resize(size.value); if( value.size() ) s.read( value.data(), value.size() ); @@ -428,7 +427,6 @@ namespace fc { --_max_depth; unsigned_int size; fc::raw::unpack( s, size, _max_depth ); value.clear(); - FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE ); value.reserve( std::min( size.value, FC_MAX_PREALLOC_SIZE ) ); for( uint32_t i = 0; i < size.value; ++i ) { @@ -474,7 +472,6 @@ namespace fc { --_max_depth; unsigned_int size; fc::raw::unpack( s, size, _max_depth ); value.clear(); - FC_ASSERT( size.value*(sizeof(K)+sizeof(V)) < MAX_ARRAY_ALLOC_SIZE ); value.reserve( std::min( size.value, FC_MAX_PREALLOC_SIZE ) ); for( uint32_t i = 0; i < size.value; ++i ) { @@ -502,7 +499,6 @@ namespace fc { --_max_depth; unsigned_int size; fc::raw::unpack( s, size, _max_depth ); value.clear(); - FC_ASSERT( size.value*(sizeof(K)+sizeof(V)) < MAX_ARRAY_ALLOC_SIZE ); for( uint32_t i = 0; i < size.value; ++i ) { std::pair tmp; @@ -529,7 +525,6 @@ namespace fc { FC_ASSERT( _max_depth > 0 ); --_max_depth; unsigned_int size; fc::raw::unpack( s, size, _max_depth ); - FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE ); value.resize( std::min( size.value, FC_MAX_PREALLOC_SIZE ) ); for( uint64_t i = 0; i < size; i++ ) { @@ -557,7 +552,6 @@ namespace fc { FC_ASSERT( _max_depth > 0 ); --_max_depth; unsigned_int size; fc::raw::unpack( s, size, _max_depth ); - FC_ASSERT( size.value*sizeof(T) < MAX_ARRAY_ALLOC_SIZE ); value.resize( std::min( size.value, FC_MAX_PREALLOC_SIZE ) ); for( uint64_t i = 0; i < size; i++ ) { diff --git a/include/fc/io/raw_fwd.hpp b/include/fc/io/raw_fwd.hpp index 87a9208..638e559 100644 --- a/include/fc/io/raw_fwd.hpp +++ b/include/fc/io/raw_fwd.hpp @@ -12,8 +12,6 @@ #include #include -#define MAX_ARRAY_ALLOC_SIZE (1024*1024*10) - namespace fc { class time_point; class time_point_sec; diff --git a/include/fc/io/raw_variant.hpp b/include/fc/io/raw_variant.hpp index bf4ad08..aa44c95 100644 --- a/include/fc/io/raw_variant.hpp +++ b/include/fc/io/raw_variant.hpp @@ -143,7 +143,6 @@ namespace fc { namespace raw { --_max_depth; unsigned_int vs; unpack( s, vs, _max_depth ); - FC_ASSERT( vs.value*sizeof(variant_object::entry) < MAX_ARRAY_ALLOC_SIZE ); mutable_variant_object mvo; mvo.reserve( std::min( vs.value, FC_MAX_PREALLOC_SIZE ) ); for( uint32_t i = 0; i < vs.value; ++i ) From fa0798423438e71b1de60de0018194f3c4fbcf6a Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 21 Jan 2019 09:11:11 -0500 Subject: [PATCH 2/3] fix overly agressive cleanup --- include/fc/io/raw.hpp | 1 + include/fc/io/raw_fwd.hpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 15c6bad..c9d344d 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -261,6 +261,7 @@ namespace fc { template inline void unpack( Stream& s, std::vector& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); unsigned_int size; fc::raw::unpack( s, size, _max_depth - 1 ); + FC_ASSERT( size.value < MAX_ARRAY_ALLOC_SIZE ); value.resize(size.value); if( value.size() ) s.read( value.data(), value.size() ); diff --git a/include/fc/io/raw_fwd.hpp b/include/fc/io/raw_fwd.hpp index 638e559..8267afc 100644 --- a/include/fc/io/raw_fwd.hpp +++ b/include/fc/io/raw_fwd.hpp @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include @@ -12,6 +12,8 @@ #include #include +#define MAX_ARRAY_ALLOC_SIZE (1024*1024*10) + namespace fc { class time_point; class time_point_sec; From 7de33aa33a99ad9522ba01a25420e66eaf494ae4 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 21 Jan 2019 09:15:56 -0500 Subject: [PATCH 3/3] whitespace only --- include/fc/io/raw_fwd.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/io/raw_fwd.hpp b/include/fc/io/raw_fwd.hpp index 8267afc..87a9208 100644 --- a/include/fc/io/raw_fwd.hpp +++ b/include/fc/io/raw_fwd.hpp @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include