fix corruption check

This commit is contained in:
Brian Pugh 2023-08-17 15:07:19 -07:00
parent df238ebac6
commit 6de3fc6ae8
1 changed files with 1 additions and 2 deletions

3
lfs.c
View File

@ -46,8 +46,7 @@ static int lfs_bd_read(lfs_t *lfs,
lfs_block_t block, lfs_off_t off,
void *buffer, lfs_size_t size) {
uint8_t *data = buffer;
if (lfs->block_count &&
(block >= lfs->block_count || off+size > lfs->cfg->block_size)) {
if (off+size > lfs->cfg->block_size || (lfs->block_count && block >= lfs->block_count)) {
return LFS_ERR_CORRUPT;
}