From 5a5449d4eb46465e5d47fb20104e13122ea4110b Mon Sep 17 00:00:00 2001 From: Krzysztof Blazewicz Date: Sat, 20 Aug 2016 16:59:53 +0200 Subject: [PATCH] extmod/modbtree: do CHECK_ERROR after __bt_seq() In `btree_seq()`, when `__bt_seq()` gets called with invalid `flags` argument it will return `RET_ERROR` and it won't initialize `val`. If field `data` of uninitialized `val` is passed to `mp_obj_new_bytes()` it causes a segfault. --- extmod/modbtree.c | 1 + 1 file changed, 1 insertion(+) diff --git a/extmod/modbtree.c b/extmod/modbtree.c index f21e7e4421..ea2ea582c8 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -133,6 +133,7 @@ STATIC mp_obj_t btree_seq(size_t n_args, const mp_obj_t *args) { } int res = __bt_seq(self->db, &key, &val, flags); + CHECK_ERROR(res); if (res == RET_SPECIAL) { return mp_const_none; }