From edc92d18db3e80c95ee565075fbe81f5b79d7df1 Mon Sep 17 00:00:00 2001 From: Philip Peitsch Date: Tue, 9 Jun 2020 12:34:58 +1000 Subject: [PATCH] py/map: Clear value when re-using slot with ordered dictionaries. To adhere to the contract of mp_map_lookup, namely: MP_MAP_LOOKUP_ADD_IF_NOT_FOUND behaviour: - returns slot, with key non-null and value=MP_OBJ_NULL if it was added --- py/map.c | 1 + 1 file changed, 1 insertion(+) diff --git a/py/map.c b/py/map.c index 7a6f2233e..c18df5a9f 100644 --- a/py/map.c +++ b/py/map.c @@ -221,6 +221,7 @@ mp_map_elem_t *MICROPY_WRAP_MP_MAP_LOOKUP(mp_map_lookup)(mp_map_t * map, mp_obj_ } mp_map_elem_t *elem = map->table + map->used++; elem->key = index; + elem->value = MP_OBJ_NULL; if (!mp_obj_is_qstr(index)) { map->all_keys_are_qstrs = 0; }