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

Commit 69838de

Browse files
committed
fix(coverity): Fix coverity reported bugs
Fixes #682
1 parent 1ba500b commit 69838de

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

accelerator/core/apis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
193193
if (!req || !res) {
194194
ret = SC_OOM;
195195
ta_log_error("%s\n", ta_error_to_string(ret));
196-
return ret;
196+
goto done;
197197
}
198198

199199
ret = recv_mam_message_req_deserialize(obj, req);

accelerator/core/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ status_t ta_get_bundles_by_addr(const iota_client_service_t* const service, tryt
481481
ret = ta_get_bundle(service, bundle_hash, bundle);
482482
if (ret != SC_OK) {
483483
ta_log_error("%s\n", ta_error_to_string(ret));
484+
bundle_transactions_free(&bundle);
484485
goto done;
485486
}
486487

@@ -542,7 +543,8 @@ status_t ta_update_node_connection(ta_config_t* const ta_conf, iota_client_servi
542543
status_t ret = SC_OK;
543544
for (int i = 0; i < MAX_NODE_LIST_ELEMENTS && ta_conf->iota_host_list[i]; i++) {
544545
// update new IOTA full node
545-
strncpy(service->http.host, ta_conf->iota_host_list[i], HOST_MAX_LEN);
546+
strncpy(service->http.host, ta_conf->iota_host_list[i], HOST_MAX_LEN - 1);
547+
service->http.host[HOST_MAX_LEN - 1] = '\0';
546548
service->http.port = ta_conf->iota_port_list[i];
547549
ta_log_info("Try to connect to %s:%d\n", service->http.host, service->http.port);
548550

accelerator/core/mam_core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ static bool is_setting_changed(const iota_client_service_t *const service, mam_a
334334
bool changed = true;
335335
find_transactions_req_t *txn_req = find_transactions_req_new();
336336
transaction_array_t *txn_res = transaction_array_new();
337+
if (!txn_req || !txn_res) {
338+
ta_log_error("%s\n", ta_error_to_string(SC_OOM));
339+
goto done;
340+
}
337341

338342
if (mam_api_channel_create(api, channel_depth, chid) != RC_OK) {
339343
ta_log_error("%s\n", ta_error_to_string(SC_MAM_FAILED_CREATE_OR_GET_ID));
@@ -346,7 +350,7 @@ static bool is_setting_changed(const iota_client_service_t *const service, mam_a
346350
// TODO use `ta_find_transaction_objects(service, txn_req, txn_res)` instead of the original 'iota.c' function
347351
retcode_t ret_rc = iota_client_find_transaction_objects(service, txn_req, txn_res);
348352
if (ret_rc && ret_rc != RC_NULL_PARAM) {
349-
ta_log_error("%s\n", SC_MAM_FAILED_DESTROYED);
353+
ta_log_error("%s\n", ta_error_to_string(SC_MAM_FAILED_DESTROYED));
350354
goto done;
351355
}
352356

connectivity/mqtt/duplex_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ status_t duplex_config_init(struct mosquitto **config_mosq, mosq_config_t *confi
4747
init_check_error(config_cfg, client_pub);
4848

4949
*config_mosq = mosquitto_new(config_cfg->general_config->id, true, NULL);
50-
if (!config_mosq) {
50+
if (!(*config_mosq)) {
5151
switch (errno) {
5252
case ENOMEM:
5353
ta_log_error("%s\n", "Out of memory");

storage/scylladb_permanode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ static status_t get_trytes(CassSession* session, CassStatement* statement, hash8
339339
if (hash8019_queue_push(res_queue, (flex_trit_t const* const)buf) != RC_OK) {
340340
ta_log_error("%s\n", "SC_OOM");
341341
ret = SC_OOM;
342+
goto end_iterate;
342343
}
343344
ret = SC_OK;
344345
}

0 commit comments

Comments
 (0)