extmod/vfs_blockdev: Check return type is an integer.

This catches cases where the return type is not a small int, eg it could be
a string, or even a big integer.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-09-16 13:15:10 +10:00
parent 6d65882b05
commit 7681c68392
3 changed files with 17 additions and 17 deletions

View File

@@ -69,7 +69,7 @@ static int mp_vfs_blockdev_call_rw(mp_obj_t *args, size_t block_num, size_t bloc
// and negative integer on errors. Check for positive integer
// results as some callers (i.e. littlefs) will produce corrupt
// results from these.
int i = MP_OBJ_SMALL_INT_VALUE(ret);
int i = mp_obj_get_int(ret);
return i > 0 ? (-MP_EINVAL) : i;
}
}