Skip to content

Commit

Permalink
GH-1062 Fix issue with variant internal variant_object being shared
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed May 8, 2023
1 parent a7c5d3c commit 0966651
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions libraries/libfc/include/fc/variant_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,15 @@ namespace fc
///@}


explicit mutable_variant_object( variant v )
:_key_value( new std::vector<entry>() )
{
*this = v.get_object();
}

template<typename T,
typename = std::enable_if_t<!std::is_base_of<mutable_variant_object,
std::decay_t<T>>::value>>
typename = std::enable_if_t<!std::is_base_of<mutable_variant_object, std::decay_t<T>>::value &&
!std::is_base_of<variant, std::decay_t<T>>::value>>
explicit mutable_variant_object( T&& v )
:_key_value( new std::vector<entry>() )
{
Expand Down
4 changes: 2 additions & 2 deletions tests/trx_generator/trx_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace eosio::testing {
void update_key_word_fields_in_sub_action(const std::string& key, fc::mutable_variant_object& action_mvo, const std::string& action_inner_key,
const std::string& key_word) {
if (action_mvo.find(action_inner_key) != action_mvo.end()) {
auto inner = action_mvo[action_inner_key].get_object();
const auto& inner = action_mvo[action_inner_key].get_object();
if (inner.find(key) != inner.end()) {
fc::mutable_variant_object inner_mvo = fc::mutable_variant_object(inner);
inner_mvo.set(key, key_word);
Expand Down Expand Up @@ -235,7 +235,7 @@ namespace eosio::testing {

const std::string gen_acct_name_per_trx("ACCT_PER_TRX");

auto action_array = unpacked_actions_data_json.get_array();
const auto& action_array = unpacked_actions_data_json.get_array();
_unpacked_actions.reserve(action_array.size());
std::transform(action_array.begin(), action_array.end(), std::back_inserter(_unpacked_actions),
[&](const auto& var) {
Expand Down

0 comments on commit 0966651

Please sign in to comment.