Skip to content

Commit

Permalink
GH-677 Fix some uses of std::move
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Feb 7, 2023
1 parent b1af6cf commit a10d6bc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libraries/chain/abi_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,11 @@ namespace eosio { namespace chain {
variants.clear();
action_results.clear();

for( auto& st : abi.structs )
structs[st.name] = std::move(st);
for( auto& st : abi.structs ) {
// side effect rules indicate std::move can happen before st.name is accessed.
auto n = st.name;
structs[std::move(n)] = std::move(st);
}

for( auto& td : abi.types ) {
EOS_ASSERT(!_is_type(td.new_type_name, ctx), duplicate_abi_type_def_exception,
Expand All @@ -167,8 +170,11 @@ namespace eosio { namespace chain {
for( auto& e : abi.error_messages )
error_messages[std::move(e.error_code)] = std::move(e.error_msg);

for( auto& v : abi.variants.value )
variants[v.name] = std::move(v);
for( auto& v : abi.variants.value ) {
// Not strictly necessary since trivially copyable, but error on safe side in case name becomes std::string
auto n = v.name;
variants[std::move(n)] = std::move(v);
}

for( auto& r : abi.action_results.value )
action_results[std::move(r.name)] = std::move(r.result_type);
Expand Down

0 comments on commit a10d6bc

Please sign in to comment.