Skip to content

Commit ef8b297

Browse files
committed
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')"
1 parent 34043c2 commit ef8b297

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

py/objtype.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *pos_args
106106
// copy in args
107107
memcpy(args2, pos_args, n_args * sizeof(mp_obj_t));
108108
// copy in kwargs
109-
memcpy(args2 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t));
109+
if (n_kw) {
110+
memcpy(args2 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t));
111+
}
110112
self->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args2);
111113
m_del(mp_obj_t, args2, n_args + 2 * n_kw);
112114

0 commit comments

Comments
 (0)