From bf904b238d7fa1a6eb82427ec803170f84c0b2e8 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 13 Feb 2016 21:53:43 +0200 Subject: [PATCH] extmod/fsusermount: umount: Add NULL pointer checks. --- extmod/fsusermount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extmod/fsusermount.c b/extmod/fsusermount.c index 677961ea39..3265465c54 100644 --- a/extmod/fsusermount.c +++ b/extmod/fsusermount.c @@ -160,14 +160,14 @@ STATIC mp_obj_t fatfs_umount(mp_obj_t bdev_or_path_in) { const char *mnt_str = mp_obj_str_get_data(bdev_or_path_in, &mnt_len); for (; i < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount)); ++i) { fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[i]; - if (!memcmp(mnt_str, vfs->str, mnt_len + 1)) { + if (vfs != NULL && !memcmp(mnt_str, vfs->str, mnt_len + 1)) { break; } } } else { for (; i < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount)); ++i) { fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[i]; - if (bdev_or_path_in == vfs->readblocks[1]) { + if (vfs != NULL && bdev_or_path_in == vfs->readblocks[1]) { break; } }