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

Commit

Permalink
fix(core): Fix resource leak in error occuring
Browse files Browse the repository at this point in the history
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
  • Loading branch information
howjmay committed Jan 13, 2020
1 parent 83ba4b7 commit 268487b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions accelerator/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,12 @@ status_t ta_get_bundles_by_addr(const iota_client_service_t* const service, tryt
}

iota_transaction_t* curr_tx = NULL;
bundle_transactions_t* bundle = NULL;
TX_OBJS_FOREACH(obj_res, curr_tx) {
bundle_transactions_new(&bundle);
flex_trits_to_trytes(bundle_hash, NUM_TRYTES_BUNDLE, transaction_bundle(curr_tx), NUM_TRITS_BUNDLE,
NUM_TRITS_BUNDLE);

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

done:
bundle_transactions_free(&bundle);
find_transactions_req_free(&txn_req);
find_transactions_res_free(&txn_res);
ta_find_transaction_objects_req_free(&obj_req);
Expand Down

0 comments on commit 268487b

Please sign in to comment.