Merge pull request #59 from rahmanih/fix_issue_58

fix: "array out of bounds" error leading to memory corruption
This commit is contained in:
Frédéric Desbiens
2025-11-25 10:09:17 -05:00
committed by GitHub
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
# Set up the project # Set up the project
project(levelx project(levelx
@@ -290,7 +290,7 @@ ULONG block_word;
/* Loop through the memory supplied and assign to cache entries. */ /* Loop through the memory supplied and assign to cache entries. */
i = 0; i = 0;
while (cache_size >= LX_NOR_SECTOR_SIZE) while ((cache_size >= LX_NOR_SECTOR_SIZE) && (i < LX_NOR_EXTENDED_CACHE_SIZE))
{ {
/* Setup this cache entry. */ /* Setup this cache entry. */
@@ -309,7 +309,7 @@ ULONG block_word;
} }
/* Save the number of cache entries. */ /* Save the number of cache entries. */
if(i > LX_NOR_EXTENDED_CACHE_SIZE) if(i == LX_NOR_EXTENDED_CACHE_SIZE)
{ {
nor_flash -> lx_nor_flash_extended_cache_entries = LX_NOR_EXTENDED_CACHE_SIZE; nor_flash -> lx_nor_flash_extended_cache_entries = LX_NOR_EXTENDED_CACHE_SIZE;