liballocs icon indicating copy to clipboard operation
liballocs copied to clipboard

Incorrect calculation of bit index in bitmap_delete?

Open muffpy opened this issue 2 years ago • 1 comments

In generic_malloc.c:

bitmap_clear_l(bitmap, ((uintptr_t) userptr - (uintptr_t) info->bitmap_base_addr) / (MALLOC_ALIGN * BITMAP_WORD_NBITS))

...wouldn't dividing by BITMAP_WORD_NBITS not give us the intended bit index but instead the bitmap index within bitmap_word_t *bitmap? In fact, we divide by BITMAP_WORD_NBITS again in librunt/bitmap.h presumably to get the bitmap index there.

Proposing instead: bitmap_clear_l(bitmap, ((uintptr_t) userptr - (uintptr_t) info->bitmap_base_addr) / MALLOC_ALIGN)

muffpy avatar Mar 30 '22 20:03 muffpy

Thanks for this. I think you are right! I can fix a bit later, or feel free to pull-request.

stephenrkell avatar Mar 30 '22 21:03 stephenrkell

I believe this is now fixed.

stephenrkell avatar Jan 05 '23 15:01 stephenrkell