This repository was archived by the owner on Dec 26, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,17 @@ flex_trit_t* ta_pow_flex(const flex_trit_t* const trits_in, const uint8_t mwm) {
39
39
status_t ta_pow (const bundle_transactions_t * bundle ,
40
40
const flex_trit_t * const trunk , const flex_trit_t * const branch ,
41
41
const uint8_t mwm ) {
42
+ status_t ret = SC_OK ;
42
43
iota_transaction_t * tx ;
43
44
flex_trit_t * ctrunk =
44
45
(flex_trit_t * )calloc (FLEX_TRIT_SIZE_243 , sizeof (flex_trit_t ));
45
46
size_t cur_idx = 0 ;
46
47
47
48
tx = (iota_transaction_t * )utarray_front (bundle );
49
+ if (tx == NULL ) {
50
+ ret = SC_TA_NULL ;
51
+ goto done ;
52
+ }
48
53
cur_idx = transaction_last_index (tx ) + 1 ;
49
54
memcpy (ctrunk , trunk , FLEX_TRIT_SIZE_243 );
50
55
@@ -60,13 +65,15 @@ status_t ta_pow(const bundle_transactions_t* bundle,
60
65
61
66
flex_trit_t * tx_trits = transaction_serialize (tx );
62
67
if (tx_trits == NULL ) {
63
- return SC_CCLIENT_INVALID_FLEX_TRITS ;
68
+ ret = SC_CCLIENT_INVALID_FLEX_TRITS ;
69
+ goto done ;
64
70
}
65
71
66
72
// get nonce
67
73
flex_trit_t * nonce = ta_pow_flex (tx_trits , mwm );
68
74
if (nonce == NULL ) {
69
- return SC_TA_OOM ;
75
+ ret = SC_TA_OOM ;
76
+ goto done ;
70
77
}
71
78
transaction_set_nonce (tx , nonce );
72
79
@@ -76,6 +83,7 @@ status_t ta_pow(const bundle_transactions_t* bundle,
76
83
free (tx_trits );
77
84
} while (cur_idx != 0 );
78
85
86
+ done :
79
87
free (ctrunk );
80
- return SC_OK ;
88
+ return ret ;
81
89
}
You can’t perform that action at this time.
0 commit comments