diff --git a/src/xrp/xrp_helpers.c b/src/xrp/xrp_helpers.c index 5d79cce3..01eed28a 100644 --- a/src/xrp/xrp_helpers.c +++ b/src/xrp/xrp_helpers.c @@ -84,11 +84,16 @@ void xrp_public_key_hash160(xrp_pubkey_t *pubkey, uint8_t *out) { cx_ripemd160_t riprip; } u; uint8_t buffer[32]; + cx_err_t error = CX_INTERNAL_ERROR; cx_sha256_init(&u.shasha); - cx_hash_no_throw(&u.shasha.header, CX_LAST, pubkey->buf, sizeof(pubkey->buf), buffer, 32); + error = + cx_hash_no_throw(&u.shasha.header, CX_LAST, pubkey->buf, sizeof(pubkey->buf), buffer, 32); + if (error != CX_OK) return; cx_ripemd160_init(&u.riprip); cx_hash_no_throw(&u.riprip.header, CX_LAST, buffer, 32, out, 20); + // Make scan-build happy + if (error != CX_OK) return; } size_t xrp_public_key_to_encoded_base58(xrp_pubkey_t *pubkey, @@ -99,6 +104,7 @@ size_t xrp_public_key_to_encoded_base58(xrp_pubkey_t *pubkey, unsigned char checksum_buffer[32]; cx_sha256_t hash; unsigned char version_size = (version > 255 ? 2 : 1); + cx_err_t error = CX_INTERNAL_ERROR; if (version > 255) { tmp.buf[0] = (version >> 8u); @@ -115,9 +121,12 @@ size_t xrp_public_key_to_encoded_base58(xrp_pubkey_t *pubkey, } cx_sha256_init(&hash); - cx_hash_no_throw(&hash.header, CX_LAST, tmp.buf, 20 + version_size, checksum_buffer, 32); + error = + cx_hash_no_throw(&hash.header, CX_LAST, tmp.buf, 20 + version_size, checksum_buffer, 32); + if (error != CX_OK) return 0; cx_sha256_init(&hash); - cx_hash_no_throw(&hash.header, CX_LAST, checksum_buffer, 32, checksum_buffer, 32); + error = cx_hash_no_throw(&hash.header, CX_LAST, checksum_buffer, 32, checksum_buffer, 32); + if (error != CX_OK) return 0; memmove(tmp.buf + 20 + version_size, checksum_buffer, 4); tmp.length = 24 + version_size;