sfree_check_redzone is passed a pointer to the address of the *header* of an allocated block. This does not match the address of any of the buffers returned by smalloc. Adjust the value printed out to refer to the address returned by smalloc associated with the header in question. This makes debugging easier because it allows us to more easily identify the buffer where over-/under-run occurred. Signed-off-by: Vincent Fu <vincent.fu@xxxxxxxxxxx> --- smalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smalloc.c b/smalloc.c index fa00f0ee..23243054 100644 --- a/smalloc.c +++ b/smalloc.c @@ -283,13 +283,13 @@ static void sfree_check_redzone(struct block_hdr *hdr) if (hdr->prered != SMALLOC_PRE_RED) { log_err("smalloc pre redzone destroyed!\n" " ptr=%p, prered=%x, expected %x\n", - hdr, hdr->prered, SMALLOC_PRE_RED); + hdr+1, hdr->prered, SMALLOC_PRE_RED); assert(0); } if (*postred != SMALLOC_POST_RED) { log_err("smalloc post redzone destroyed!\n" " ptr=%p, postred=%x, expected %x\n", - hdr, *postred, SMALLOC_POST_RED); + hdr+1, *postred, SMALLOC_POST_RED); assert(0); } } -- 2.25.1