wolfcrypt/src/sp_int.c: in _sp_prime_trials(), use DECL_SP_INT() not DECL_SP_INT_ARRAY() for n1 and r, to mollify a very confused clang-tidy (fixes false positive clang-analyzer-core.UndefinedBinaryOperatorResult and clang-analyzer-core.CallAndMessage).

This commit is contained in:
Daniel Pouzzner
2025-06-20 14:52:42 -05:00
parent 0f119ab8e2
commit e1fe186753

View File

@ -19271,18 +19271,15 @@ static int _sp_prime_trials(const sp_int* a, int trials, int* result)
{
int err = MP_OKAY;
int i;
sp_int* n1;
sp_int* r;
DECL_SP_INT_ARRAY(t, a->used + 1, 2);
DECL_SP_INT(n1, a->used + 1);
DECL_SP_INT(r, a->used + 1);
DECL_SP_INT(b, a->used * 2 + 1);
ALLOC_SP_INT_ARRAY(t, a->used + 1, 2, err, NULL);
ALLOC_SP_INT(n1, a->used + 1, err, NULL);
ALLOC_SP_INT(r, a->used + 1, err, NULL);
/* Allocate number that will hold modular exponentiation result. */
ALLOC_SP_INT(b, a->used * 2 + 1, err, NULL);
if (err == MP_OKAY) {
n1 = t[0];
r = t[1];
_sp_init_size(n1, a->used + 1U);
_sp_init_size(r, a->used + 1U);
_sp_init_size(b, (sp_size_t)(a->used * 2U + 1U));
@ -19305,7 +19302,8 @@ static int _sp_prime_trials(const sp_int* a, int trials, int* result)
/* Free allocated temporary. */
FREE_SP_INT(b, NULL);
FREE_SP_INT_ARRAY(t, NULL);
FREE_SP_INT(r, NULL);
FREE_SP_INT(n1, NULL);
return err;
}