summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ext2fs/alloc_tables.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index fec9003e..bc99943c 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -54,8 +54,8 @@ static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
* Don't do a long search if the previous block
* search is still valid.
*/
- if (start_blk && ext2fs_test_block_bitmap_range2(bmap, start_blk,
- elem_size))
+ if (start_blk && start_blk < ext2fs_blocks_count(fs->super) &&
+ ext2fs_test_block_bitmap_range2(bmap, start_blk, elem_size))
return start_blk;
start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg);