From 04655aa3f16fe5f8d70a71b3fa6d9555cbc078c6 Mon Sep 17 00:00:00 2001 From: Todd Fleming Date: Mon, 17 Dec 2018 15:45:56 -0500 Subject: [PATCH] state history plugin: permission_object bug #6495 --- .../state_history_serialization.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp index b20f264598e..b000ac78803 100644 --- a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp +++ b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp @@ -325,10 +325,20 @@ datastream& operator<<(datastream& ds, const history_serial_wrapper(obj.obj.owner.value)); fc::raw::pack(ds, as_type(obj.obj.name.value)); - if (obj.obj.parent._id) - fc::raw::pack(ds, as_type(obj.db.get(obj.obj.parent).name.value)); - else + if (obj.obj.parent._id) { + auto& index = obj.db.get_index(); + const auto* parent = index.find(obj.obj.parent); + if (!parent) { + auto& undo = index.stack().back(); + auto it = undo.removed_values.find(obj.obj.parent); + EOS_ASSERT(it != undo.removed_values.end(), eosio::chain::plugin_exception, + "can not find parent of permission_object"); + parent = &it->second; + } + fc::raw::pack(ds, as_type(parent->name.value)); + } else { fc::raw::pack(ds, as_type(0)); + } fc::raw::pack(ds, as_type(obj.obj.last_updated)); fc::raw::pack(ds, make_history_serial_wrapper(obj.db, as_type(obj.obj.auth))); return ds;