Avoid null pointer dereference when no kwargs

clang scan-build reports "Access to field 'table' results in a
dereference of a null pointer (loaded from variable 'kw_args')"
This commit is contained in:
Jeff Epler 2023-01-01 16:56:46 -06:00
parent 34043c2d38
commit ef8b297d7f
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
1 changed files with 3 additions and 1 deletions

View File

@ -106,7 +106,9 @@ STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *pos_args
// copy in args
memcpy(args2, pos_args, n_args * sizeof(mp_obj_t));
// copy in kwargs
memcpy(args2 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t));
if (n_kw) {
memcpy(args2 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t));
}
self->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args2);
m_del(mp_obj_t, args2, n_args + 2 * n_kw);