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.
pull/2344/merge
Krzysztof Blazewicz 2016-08-20 16:59:53 +02:00 zatwierdzone przez Paul Sokolovsky
rodzic 253e1a6f67
commit 5a5449d4eb
1 zmienionych plików z 1 dodań i 0 usunięć

Wyświetl plik

@ -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;
}