Skip to content

Commit

Permalink
Do not allow nullptr stack elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Aug 23, 2024
1 parent 935bf7a commit c90b6d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/chain/witness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ void witness::assign_data(reader& source, bool prefix) NOEXCEPT

for (size_t element = 0; element < count; ++element)
{
// If read_bytes_raw returns nullptr invalid source is implied.
const auto size = source.read_size(max_block_weight);
const auto bytes = source.read_bytes_raw(size);
if (is_null(bytes))
break;

stack_.emplace_back(POINTER(data_chunk, allocator, bytes));
size_ = element_size(size_, stack_.back());
}
Expand All @@ -186,8 +190,12 @@ void witness::assign_data(reader& source, bool prefix) NOEXCEPT
{
while (!source.is_exhausted())
{
// If read_bytes_raw returns nullptr invalid source is implied.
const auto size = source.read_size(max_block_weight);
const auto bytes = source.read_bytes_raw(size);
if (is_null(bytes))
break;

stack_.emplace_back(POINTER(data_chunk, allocator, bytes));
size_ = element_size(size_, stack_.back());
}
Expand Down

0 comments on commit c90b6d9

Please sign in to comment.