summaryrefslogtreecommitdiff
path: root/py/map.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-04-23 01:10:30 +1000
committerDamien George <damien.p.george@gmail.com>2020-04-27 23:53:17 +1000
commit57fce3bdb203e9701dbd81ee108189898e19911b (patch)
treebffc02c12f2c5c78e082bec83e903c793cea778b /py/map.c
parent347c8917dc8d2785fdbd8c9a0f554219e6216647 (diff)
py/objdict: Fix popitem for ordered dicts.
The popitem method wasn't implemented for ordered dicts and would result in an invalid state. Fixes issue #5956.
Diffstat (limited to 'py/map.c')
-rw-r--r--py/map.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/map.c b/py/map.c
index 2570941bf..676c364da 100644
--- a/py/map.c
+++ b/py/map.c
@@ -177,6 +177,7 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
--map->used;
memmove(elem, elem + 1, (top - elem - 1) * sizeof(*elem));
// put the found element after the end so the caller can access it if needed
+ // note: caller must NULL the value so the GC can clean up (e.g. see dict_get_helper).
elem = &map->table[map->used];
elem->key = MP_OBJ_NULL;
elem->value = value;