Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 268487b

Browse files
committed
fix(core): Fix resource leak in error occuring
When occuring error at line 539 in `core.c` the program would jump to the label `done`. At this scenario, variable `bundle` would not be freed
1 parent 83ba4b7 commit 268487b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

accelerator/core/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,12 @@ status_t ta_get_bundles_by_addr(const iota_client_service_t* const service, tryt
518518
}
519519

520520
iota_transaction_t* curr_tx = NULL;
521+
bundle_transactions_t* bundle = NULL;
521522
TX_OBJS_FOREACH(obj_res, curr_tx) {
523+
bundle_transactions_new(&bundle);
522524
flex_trits_to_trytes(bundle_hash, NUM_TRYTES_BUNDLE, transaction_bundle(curr_tx), NUM_TRITS_BUNDLE,
523525
NUM_TRITS_BUNDLE);
524526

525-
bundle_transactions_t* bundle = NULL;
526-
bundle_transactions_new(&bundle);
527527
ret = ta_get_bundle(service, bundle_hash, bundle);
528528
if (ret != SC_OK) {
529529
ta_log_error("%d\n", ret);
@@ -537,6 +537,7 @@ status_t ta_get_bundles_by_addr(const iota_client_service_t* const service, tryt
537537
}
538538

539539
done:
540+
bundle_transactions_free(&bundle);
540541
find_transactions_req_free(&txn_req);
541542
find_transactions_res_free(&txn_res);
542543
ta_find_transaction_objects_req_free(&obj_req);

0 commit comments

Comments
 (0)