Skip to content

Commit

Permalink
Merge pull request #1649 from AntelopeIO/no_nullptr_memcpy_getactiondata
Browse files Browse the repository at this point in the history
avoid possible memcpy with nullptr when action data size is 0
  • Loading branch information
spoonincode authored Sep 18, 2023
2 parents cf0d9f4 + 0e1d5fa commit 7be27dc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libraries/chain/webassembly/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
namespace eosio { namespace chain { namespace webassembly {
int32_t interface::read_action_data(legacy_span<char> memory) const {
auto s = context.get_action().data.size();
if( memory.size() == 0 ) return s;

auto copy_size = std::min( static_cast<size_t>(memory.size()), s );
if( copy_size == 0 ) return s;
std::memcpy( memory.data(), context.get_action().data.data(), copy_size );

return copy_size;
Expand Down

0 comments on commit 7be27dc

Please sign in to comment.