Skip to content

Commit

Permalink
Merge pull request libbitcoin#432 from evoskuil/master
Browse files Browse the repository at this point in the history
Deallocate after block destruct (safety).
  • Loading branch information
evoskuil authored Aug 22, 2024
2 parents d2029ec + 87211b6 commit e2de742
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/messages/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ typename block::cptr block::deserialize(arena& arena, uint32_t version,
return to_shared<messages::block>(std::shared_ptr<chain::block>(block,
[&arena, memory](auto) NOEXCEPT
{
// Deallocate detached memory (nop if not detachable).
arena.release(memory);

// Destruct and deallocate objects (nop deallocate if detachable).
byte_allocator::deleter<chain::block>(&arena);

// Deallocate detached memory (nop if not detachable).
// Follows destructor just in case a destructor traverses memory.
arena.release(memory);
}));
}

Expand Down

0 comments on commit e2de742

Please sign in to comment.