...
 
Commits (3)
......@@ -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 || lhs->dig == NULL || rhs->len == 0) {
if (lhs->len == 0 || rhs->len == 0) {
mpz_set_from_int(dest, 0);
return;
}
......@@ -1313,6 +1313,9 @@ void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
rhs = temp = mpz_clone(rhs);
}
// Appease static analysers
if (lhs->dig == NULL || rhs->dig == NULL) { mpz_set_from_int(dest, 0); return; }
mpz_need_dig(dest, lhs->len + rhs->len); // min mem l+r-1, max mem l+r
memset(dest->dig, 0, dest->alloc * sizeof(mpz_dig_t));
dest->len = mpn_mul(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len);
......@@ -1335,7 +1338,7 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
return;
}
if (rhs->len == 0 || rhs->dig == NULL) {
if (rhs->len == 0) {
mpz_set_from_int(dest, 1);
return;
}
......@@ -1343,6 +1346,9 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
mpz_t *x = mpz_clone(lhs);
mpz_t *n = mpz_clone(rhs);
// Appease static analysers
if (n->dig == NULL) { mpz_set_from_int(dest, 0); return; }
mpz_set_from_int(dest, 1);
while (n->len > 0) {
......@@ -1371,12 +1377,16 @@ 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 || rhs->dig == NULL) {
if (rhs->len == 0) {
return;
}
mpz_t *x = mpz_clone(lhs);
mpz_t *n = mpz_clone(rhs);
// Appease static analysers
if (n->dig == NULL) { mpz_set_from_int(dest, 0); return; }
mpz_t quo; mpz_init_zero(&quo);
while (n->len > 0) {
......
......@@ -45,6 +45,8 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
nlr_pop();
return value;
} else {
// Appease static analysers
if (nlr.ret_val == NULL) return MP_OBJ_STOP_ITERATION;
// an exception was raised
mp_obj_type_t *t = (mp_obj_type_t*)((mp_obj_base_t*)nlr.ret_val)->type;
if (t == &mp_type_StopIteration || t == &mp_type_IndexError) {
......
......@@ -85,7 +85,6 @@ 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);
if (native_base != NULL) {
self->subobj[0] = native_base->make_new(native_base, n_args - 1, 0, args + 1);
}
......
......@@ -1193,6 +1193,8 @@ mp_obj_t mp_iternext(mp_obj_t o_in) {
nlr_pop();
return ret;
} else {
// Appease static analysers
if (nlr.ret_val == NULL) return MP_OBJ_STOP_ITERATION;
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) {
return MP_OBJ_STOP_ITERATION;
} else {
......
......@@ -1377,6 +1377,9 @@ exception_handler:
MP_STATE_VM(cur_exception) = nlr.ret_val;
#endif
// Appease static analysers
if (nlr.ret_val == NULL) nlr.ret_val = MP_OBJ_TO_PTR(mp_obj_new_exception(&mp_type_RuntimeError));
#if SELECTIVE_EXC_IP
// with selective ip, we store the ip 1 byte past the opcode, so move ptr back
code_state->ip -= 1;
......
......@@ -105,12 +105,12 @@ char *vstr_extend(vstr_t *vstr, size_t size) {
STATIC void vstr_ensure_extra(vstr_t *vstr, size_t size) {
if (vstr->len + size > vstr->alloc) {
if (vstr->fixed_buf) {
size_t new_alloc = ROUND_ALLOC((vstr->len + size) + 16);
if (vstr->fixed_buf || new_alloc == 0) {
// We can't reallocate, and the caller is expecting the space to
// be there, so the only safe option is to raise an exception.
mp_raise_msg(&mp_type_RuntimeError, NULL);
}
size_t new_alloc = ROUND_ALLOC((vstr->len + size) + 16);
char *new_buf = m_renew(char, vstr->buf, vstr->alloc, new_alloc);
vstr->alloc = new_alloc;
vstr->buf = new_buf;
......