Skip to content

Commit 21c0d3d

Browse files
committed
fix the error searching for the empty slot
1 parent 6684250 commit 21c0d3d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lwmem/src/lwmem/lwmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ prv_insert_free_block(lwmem_t* const lwobj, lwmem_block_t* nblk) {
239239
* Try to find position to put new block in-between
240240
* Search until all free block addresses are lower than entry block
241241
*/
242-
for (prev = &(lwobj->start_block); prev != NULL && prev->next < nblk; prev = prev->next) {}
242+
for (prev = &(lwobj->start_block); prev != NULL && prev->next != NULL && prev->next < nblk; prev = prev->next) {}
243243

244244
/* This is hard error with wrong memory usage */
245245
if (prev == NULL) {

0 commit comments

Comments
 (0)