diff --git a/modules/common/dap_chain_datum_tx_items.c b/modules/common/dap_chain_datum_tx_items.c index 6bcc83c9e4325fe0750c24cbed8c92c97c725687..757c27c11f7893460efa74d3bb8fa397818f8942 100644 --- a/modules/common/dap_chain_datum_tx_items.c +++ b/modules/common/dap_chain_datum_tx_items.c @@ -536,6 +536,8 @@ uint8_t *dap_chain_datum_tx_item_get_nth(dap_chain_datum_tx_t *a_tx, dap_chain_t */ dap_chain_tx_out_cond_t *dap_chain_datum_tx_out_cond_get(dap_chain_datum_tx_t *a_tx, dap_chain_tx_out_cond_subtype_t a_cond_subtype, int *a_out_num) { + if (!a_tx) + return NULL; int l_idx = a_out_num && *a_out_num > 0 ? -*a_out_num : 0; byte_t *l_item; size_t l_tx_item_size; TX_ITEM_ITER_TX(l_item, l_tx_item_size, a_tx) { diff --git a/modules/net/srv/dap_chain_net_srv.c b/modules/net/srv/dap_chain_net_srv.c index 88ca4c3c6e5f89a51e53659adb7875bd82ce1804..4ebb5f9c613db910b18c3c5f0132a26b77f52539 100644 --- a/modules/net/srv/dap_chain_net_srv.c +++ b/modules/net/srv/dap_chain_net_srv.c @@ -775,6 +775,10 @@ static int s_pay_verificator_callback(dap_ledger_t * a_ledger, dap_chain_tx_out_ dap_chain_tx_in_cond_t *l_tx_in_cond = (dap_chain_tx_in_cond_t*)dap_chain_datum_tx_item_get(a_tx_in, NULL, NULL, TX_ITEM_TYPE_IN_COND, NULL); dap_chain_datum_tx_t *l_tx_prev = dap_ledger_tx_find_by_hash(a_ledger , &l_tx_in_cond->header.tx_prev_hash); dap_chain_tx_out_cond_t *l_prev_out_cond = dap_chain_datum_tx_out_cond_get(l_tx_prev, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_PAY, NULL); + if (!l_prev_out_cond) { + log_it(L_ERROR, "Can't find datum tx"); + return -15; + } uint256_t l_unit_price = {}; if (!l_receipt->receipt_info.units) { diff --git a/modules/service/stake/dap_chain_net_srv_stake_lock.c b/modules/service/stake/dap_chain_net_srv_stake_lock.c index 7a5d72bcd9cf9762641eb2dd54eb296efec5856c..84ee2e167286c8cbfe14bdbe29dce38215cf5351 100644 --- a/modules/service/stake/dap_chain_net_srv_stake_lock.c +++ b/modules/service/stake/dap_chain_net_srv_stake_lock.c @@ -1109,6 +1109,8 @@ static void s_stake_lock_callback_updater(dap_ledger_t *a_ledger, dap_chain_datu return; int l_out_num = 0; dap_chain_tx_out_cond_t *l_cond = dap_chain_datum_tx_out_cond_get(a_tx_in, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_LOCK, &l_out_num); + if (!l_cond) + return; if (l_cond->subtype.srv_stake_lock.flags & DAP_CHAIN_NET_SRV_STAKE_LOCK_FLAG_CREATE_BASE_TX) dap_ledger_emission_for_stake_lock_item_add(a_ledger, a_tx_in_hash); } diff --git a/modules/service/xchange/dap_chain_net_srv_xchange.c b/modules/service/xchange/dap_chain_net_srv_xchange.c index 7e8c19c190c14370b73f1ad8b1a185f8ffa95cd0..bc9878fc5c1ad6a3becd01ee500de1ba64d070b2 100644 --- a/modules/service/xchange/dap_chain_net_srv_xchange.c +++ b/modules/service/xchange/dap_chain_net_srv_xchange.c @@ -1146,6 +1146,8 @@ dap_chain_net_srv_xchange_price_t *s_xchange_price_from_order(dap_chain_net_t *a } l_price->creation_date = a_order->header.ts_created; dap_chain_tx_out_cond_t *l_out_cond = dap_chain_datum_tx_out_cond_get(a_order, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_XCHANGE , NULL); + if (!l_out_cond) + return NULL; strcpy(l_price->token_buy, l_out_cond->subtype.srv_xchange.buy_token); MULT_256_COIN(l_out_cond->header.value, l_out_cond->subtype.srv_xchange.rate, &l_price->datoshi_buy); @@ -1891,6 +1893,10 @@ static bool s_string_append_tx_cond_info( dap_string_t * a_reply_str, int l_out_num = l_in_cond->header.tx_out_prev_idx; dap_chain_tx_out_cond_t *l_out_cond = dap_chain_datum_tx_out_cond_get(l_prev_tx, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_XCHANGE, &l_out_num); + if (!l_out_cond) { + log_it(L_ERROR, "Can't find datum tx"); + return false; + } dap_hash_fast_t l_order_hash = dap_ledger_get_first_chain_tx_hash(a_net->pub.ledger, a_tx, l_out_cond); if ( dap_hash_fast_is_blank(&l_order_hash) ) l_order_hash = l_in_cond->header.tx_prev_hash;