From a75a141d63a8f683d2e16b6bdc0be6d790163b41 Mon Sep 17 00:00:00 2001 From: Andy Oknen Date: Tue, 22 Nov 2022 15:58:18 +0300 Subject: [PATCH] Fix check null pointer --- src/pocketdb/consensus/social/AccountUser.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pocketdb/consensus/social/AccountUser.hpp b/src/pocketdb/consensus/social/AccountUser.hpp index 3b2639c93..4bc5c38b1 100644 --- a/src/pocketdb/consensus/social/AccountUser.hpp +++ b/src/pocketdb/consensus/social/AccountUser.hpp @@ -84,15 +84,18 @@ namespace PocketConsensus if (*blockTx->GetHash() == *ptx->GetHash()) continue; - auto blockPtx = static_pointer_cast(blockTx); - if (*ptx->GetAddress() == *blockPtx->GetAddress()) + if (*ptx->GetAddress() == *blockTx->GetString1()) { if (!CheckpointRepoInst.IsSocialCheckpoint(*ptx->GetHash(), *ptx->GetType(), SocialConsensusResult_ChangeInfoDoubleInBlock)) return {false, SocialConsensusResult_ChangeInfoDoubleInBlock}; } - if (auto[ok, result] = ValidateBlockDuplicateName(ptx, blockPtx); !ok) - return {false, result}; + if (TransactionHelper::IsIn(*blockTx->GetType(), { ACCOUNT_USER })) + { + auto blockPtx = static_pointer_cast(blockTx); + if (auto[ok, result] = ValidateBlockDuplicateName(ptx, blockPtx); !ok) + return {false, result}; + } } if (GetChainCount(ptx) > GetConsensusLimit(ConsensusLimit_edit_user_daily_count)) @@ -201,10 +204,10 @@ namespace PocketConsensus // TODO (brangr): move to base class after this checkpoint - set test checkpoint records ConsensusValidateResult ValidateBlockDuplicateName(const UserRef& ptx, const UserRef& blockPtx) override { - auto ptxName = *ptx->GetPayloadName(); + auto ptxName = ptx->GetPayloadName() ? *ptx->GetPayloadName() : ""; boost::algorithm::to_lower(ptxName); - auto blockPtxName = *blockPtx->GetPayloadName(); + auto blockPtxName = blockPtx->GetPayloadName() ? *blockPtx->GetPayloadName() : ""; boost::algorithm::to_lower(blockPtxName); if (ptxName == blockPtxName)