summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-04-10 14:48:27 -0700
committerScott Shawcroft <scott@tannewt.org>2019-04-10 14:48:27 -0700
commitdebff191264c12ddd758720096a9c7d6a49e7b93 (patch)
treedc4109d61189059144d76bb5d9733c3f1ad790cb /py
parent9f4f689879caf0a97efbb55878a4d18825448e68 (diff)
Check for null local dictionaries
Diffstat (limited to 'py')
-rw-r--r--py/objtype.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/objtype.c b/py/objtype.c
index 4dec478e9..88e918827 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -966,6 +966,9 @@ STATIC bool check_for_special_accessors(mp_obj_t key, mp_obj_t value) {
}
STATIC bool map_has_special_accessors(const mp_map_t *map) {
+ if (map == NULL) {
+ return false;
+ }
for (size_t i = 0; i < map->alloc; i++) {
if (MP_MAP_SLOT_IS_FILLED(map, i)) {
const mp_map_elem_t *elem = &map->table[i];
@@ -1183,6 +1186,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
if (!(o->flags & TYPE_FLAG_HAS_SPECIAL_ACCESSORS) &&
(map_has_special_accessors(locals_map) ||
(num_native_bases == 1 &&
+ native_base->locals_dict != NULL &&
map_has_special_accessors(&native_base->locals_dict->map)))) {
o->flags |= TYPE_FLAG_HAS_SPECIAL_ACCESSORS;
}