Skip to content

Commit

Permalink
mem_link_valid ( called by MEM_SANITY() ) need to be called under pro…
Browse files Browse the repository at this point in the history
…tected conditions.

because, plug_holes which is called by mem_free will change data that used by mem_link_valid.
  • Loading branch information
wumingcaiji committed Jun 25, 2024
1 parent 86c9f79 commit 193a22d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ mem_malloc(mem_size_t size_in)
lfree = cur;
LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used)));
}
/* mem_link_valid ( called by MEM_SANITY() ) need to be called under protected conditions.
because, plug_holes which is called by mem_free will change data that used by mem_link_valid */
MEM_SANITY();
LWIP_MEM_ALLOC_UNPROTECT();
sys_mutex_unlock(&mem_mutex);
LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.",
Expand All @@ -947,7 +950,6 @@ mem_malloc(mem_size_t size_in)
#if MEM_OVERFLOW_CHECK
mem_overflow_init_element(mem, size_in);
#endif
MEM_SANITY();
return (u8_t *)mem + SIZEOF_STRUCT_MEM + MEM_SANITY_OFFSET;
}
}
Expand Down

0 comments on commit 193a22d

Please sign in to comment.