Skip to content

Commit

Permalink
guard against calling memcpy() with NULL src
Browse files Browse the repository at this point in the history
  • Loading branch information
spoonincode committed Mar 8, 2024
1 parent 33e91eb commit 407660b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/eosio/vm/execution_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ namespace eosio { namespace vm {
auto required_memory = static_cast<uint64_t>(offset) + data_seg.data.size();
EOS_VM_ASSERT(required_memory <= available_memory, wasm_memory_exception, "data out of range");
auto addr = _linear_memory + offset;
memcpy((char*)(addr), data_seg.data.data(), data_seg.data.size());
if(data_seg.data.size())
memcpy((char*)(addr), data_seg.data.data(), data_seg.data.size());
}

// Globals can be different from one WASM code to another.
Expand Down

0 comments on commit 407660b

Please sign in to comment.