From 1d8038cd47f73c8c889d01fc8d174832f9d93a1c Mon Sep 17 00:00:00 2001
From: "Constantin P." <papizh.konstantin@demlabs.net>
Date: Tue, 10 Sep 2024 16:02:35 +0700
Subject: [PATCH] Use after free in votings fix

---
 modules/service/voting/dap_chain_net_srv_voting.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/service/voting/dap_chain_net_srv_voting.c b/modules/service/voting/dap_chain_net_srv_voting.c
index 7583bc2f1b..f6ac389d96 100644
--- a/modules/service/voting/dap_chain_net_srv_voting.c
+++ b/modules/service/voting/dap_chain_net_srv_voting.c
@@ -440,10 +440,10 @@ static int s_vote_verificator(dap_ledger_t *a_ledger, dap_chain_tx_item_type_t a
                 dap_list_free(l_tsd_list);
                 // change vote & move it to the end of list
                 l_voting->votes = dap_list_remove_link(l_voting->votes, it);
-                DAP_DELETE(it->data);
                 l_voting->votes = dap_list_append(l_voting->votes, l_vote_item);
                 char l_vote_hash_str[DAP_HASH_FAST_STR_SIZE];
                 dap_hash_fast_to_str(&((dap_chain_net_vote_t *)it->data)->vote_hash, l_vote_hash_str, DAP_HASH_FAST_STR_SIZE);
+                DAP_DELETE(it->data);
                 log_it(L_INFO, "Vote %s of voting %s has been changed", l_vote_hash_str, dap_hash_fast_to_str_static(&l_voting->voting_hash));
                 return DAP_LEDGER_CHECK_OK;
             }
-- 
GitLab