...
 
Commits (4)
......@@ -434,7 +434,7 @@ STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *
size_t jl = jlen;
for (mpz_dig_t *jd = jdig; jl > 0; --jl, ++jd, ++id) {
carry += (mpz_dbl_dig_t)*id + (mpz_dbl_dig_t)*jd * (mpz_dbl_dig_t)*kdig; // will never overflow so long as DIG_SIZE <= 8*sizeof(mpz_dbl_dig_t)/2 /* polyspace DEFECT:NULL_PTR [No action planned:Low] "jd won't be NULL; kdig won't be NULL" */
carry += (mpz_dbl_dig_t)*id + (mpz_dbl_dig_t)*jd * (mpz_dbl_dig_t)*kdig; // will never overflow so long as DIG_SIZE <= 8*sizeof(mpz_dbl_dig_t)/2
*id = carry & DIG_MASK;
carry >>= DIG_SIZE;
}
......@@ -1298,7 +1298,7 @@ void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
can have dest, lhs, rhs the same
*/
void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
if (lhs->len == 0 || rhs->len == 0) {
if (lhs->len == 0 || lhs->dig == NULL || rhs->len == 0) {
mpz_set_from_int(dest, 0);
return;
}
......@@ -1335,7 +1335,7 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
return;
}
if (rhs->len == 0) {
if (rhs->len == 0 || rhs->dig == NULL) {
mpz_set_from_int(dest, 1);
return;
}
......@@ -1346,7 +1346,7 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
mpz_set_from_int(dest, 1);
while (n->len > 0) {
if ((n->dig[0] & 1) != 0) { /* polyspace DEFECT:NULL_PTR [No action planned:Low] "n->dig won't be NULL" */
if ((n->dig[0] & 1) != 0) {
mpz_mul_inpl(dest, dest, x);
}
n->len = mpn_shr(n->dig, n->dig, n->len, 1);
......@@ -1371,7 +1371,7 @@ void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t
mpz_set_from_int(dest, 1);
if (rhs->len == 0) {
if (rhs->len == 0 || rhs->dig == NULL) {
return;
}
......@@ -1380,7 +1380,7 @@ void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t
mpz_t quo; mpz_init_zero(&quo);
while (n->len > 0) {
if ((n->dig[0] & 1) != 0) { /* polyspace DEFECT:NULL_PTR [No action planned:Low] "n->dig won't be NULL" */
if ((n->dig[0] & 1) != 0) {
mpz_mul_inpl(dest, dest, x);
mpz_divmod_inpl(&quo, dest, dest, mod);
}
......
......@@ -85,7 +85,10 @@ STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *args) {
mp_obj_instance_t *self = MP_OBJ_TO_PTR(args[0]);
const mp_obj_type_t *native_base = NULL;
instance_count_native_bases(self->base.type, &native_base);
self->subobj[0] = native_base->make_new(native_base, n_args - 1, 0, args + 1); /* polyspace DEFECT:NULL_PTR [No action planned:Low] "native_base won't be NULL" */
self->subobj[0] = native_base->make_new(native_base, n_args - 1, 0, args + 1);
if (native_base != NULL) {
self->subobj[0] = native_base->make_new(native_base, n_args - 1, 0, args + 1);
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(native_base_init_wrapper_obj, 1, MP_OBJ_FUN_ARGS_MAX, native_base_init_wrapper);
......