From 710db764891940d27f0495a872bb57abdfdaed5f Mon Sep 17 00:00:00 2001
From: "Constantin P." <papizh.konstantin@demlabs.net>
Date: Fri, 31 May 2024 10:49:03 +0700
Subject: [PATCH] Memory error fix

---
 modules/type/dag/dap_chain_cs_dag.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/type/dag/dap_chain_cs_dag.c b/modules/type/dag/dap_chain_cs_dag.c
index ddbdce1eb0..07756772ce 100644
--- a/modules/type/dag/dap_chain_cs_dag.c
+++ b/modules/type/dag/dap_chain_cs_dag.c
@@ -555,7 +555,8 @@ static dap_chain_atom_verify_res_t s_chain_callback_atom_add(dap_chain_t * a_cha
     }
     pthread_mutex_unlock(&PVT(l_dag)->events_mutex);
     if (ret == ATOM_REJECT) { // Neither added, nor freed
-        DAP_DELETE(l_event_item->event);
+        if (!a_chain->is_mapped)
+            DAP_DELETE(l_event_item->event);
         DAP_DELETE(l_event_item);
     }
     return ret;
-- 
GitLab