liballocs
liballocs copied to clipboard
Incorrect calculation of bit index in bitmap_delete?
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)
Thanks for this. I think you are right! I can fix a bit later, or feel free to pull-request.
I believe this is now fixed.